├── casestudies ├── vehicleCollision │ ├── train_data_list.txt │ ├── train.sh │ ├── build_database.sh │ ├── snapshots │ │ ├── _iter_300000.caffemodel │ │ └── _iter_300000.solverstate │ ├── verify.sh │ ├── caffe_solver_with_pooling.prototxt │ ├── run100TimesTrain.py │ ├── caffe_net_with_pooling.prototxt │ ├── generator.py │ └── json_net_against_csv_robustness_verifier.py └── MNIST │ ├── snapshots │ ├── _iter_200000.caffemodel │ └── _iter_200000.solverstate │ ├── train_lenet.sh │ ├── testAccuracy.sh │ ├── lenet_solver.prototxt │ ├── lenet_train_test.prototxt │ ├── computeMNISTAccuracy.py │ └── prodNetwork.py ├── .gitignore ├── src ├── config.h ├── Tool.pro ├── minisat2 │ ├── LICENSE │ ├── IntTypes.h │ ├── XAlloc.h │ ├── README │ ├── Rnd.h │ ├── Alg.h │ ├── Queue.h │ ├── System.h │ ├── Dimacs.h │ ├── Sort.h │ ├── Options.cc │ ├── IntMap.h │ ├── ParseUtils.h │ ├── Alloc.h │ ├── System.cc │ ├── Heap.h │ ├── Vec.h │ ├── Main.cc │ ├── Map.h │ └── Options.h ├── main.cpp ├── supersetdatabase.hpp ├── supersetdatabase.cpp ├── verifierContext.hpp └── lpSolvers.hpp ├── tools ├── sumUserTimes.py ├── pngToTikz.py ├── makeParallelCheckingOfAllRLVFilesInThisDirectoryMakefile.py ├── makeYicesComparisonMakefile.py ├── makeGurobiComparisonMakefile.py ├── testBenchmarksInThisDirectory.py ├── rlvCompressor.py └── drawCactusPlotsForAllPerformanceSummariesInTheCurrentDirectory.py ├── .travis.yml ├── README.md └── benchmarks └── collisionDetection ├── reluBenchmark0.3205909729s_SAT.rlv └── reluBenchmark0.4976811409s_SAT.rlv /casestudies/vehicleCollision/train_data_list.txt: -------------------------------------------------------------------------------- 1 | collisions.hdf5 2 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/train.sh: -------------------------------------------------------------------------------- 1 | $CAFFE/build/tools/caffe train -solver caffe_solver_with_pooling.prototxt 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | casestudies/vehicleCollision/collisions.hdf5 2 | casestudies/vehicleCollision/testNetworkWithPooling.json 3 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/build_database.sh: -------------------------------------------------------------------------------- 1 | ../../tools/csv_to_hdf5_supervised_classification.py collisions.csv collisions.hdf5 2 | -------------------------------------------------------------------------------- /casestudies/MNIST/snapshots/_iter_200000.caffemodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/progirep/planet/HEAD/casestudies/MNIST/snapshots/_iter_200000.caffemodel -------------------------------------------------------------------------------- /casestudies/MNIST/train_lenet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -e 3 | 4 | ~/LocalLibs/caffe/build/tools/caffe train --solver=lenet_solver.prototxt $@ 5 | -------------------------------------------------------------------------------- /casestudies/MNIST/snapshots/_iter_200000.solverstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/progirep/planet/HEAD/casestudies/MNIST/snapshots/_iter_200000.solverstate -------------------------------------------------------------------------------- /casestudies/vehicleCollision/snapshots/_iter_300000.caffemodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/progirep/planet/HEAD/casestudies/vehicleCollision/snapshots/_iter_300000.caffemodel -------------------------------------------------------------------------------- /casestudies/vehicleCollision/snapshots/_iter_300000.solverstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/progirep/planet/HEAD/casestudies/vehicleCollision/snapshots/_iter_300000.solverstate -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_RELU_H 2 | #define __CONFIG_RELU_H 3 | 4 | 5 | #define SORT_LITERALS_BY_IMPLIED_LITERALS_FIRST_PER_DECISION_LEVEL_IN_SOLVER_WHEN_CALLING_LP_SOLVER_FOR_FEASIBILITY_CHECK 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/verify.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | unset -v latest 3 | for file in "snapshots"/_iter_*.caffemodel; do 4 | [[ $file -nt $latest ]] && latest=$file 5 | done 6 | echo $latest 7 | python ../../tools/caffemodel2json.py $CAFFE/src/caffe/proto/caffe.proto $latest --data > testNetworkWithPooling.json 8 | ./json_net_against_csv_robustness_verifier.py testNetworkWithPooling.json collisions.csv 9 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/caffe_solver_with_pooling.prototxt: -------------------------------------------------------------------------------- 1 | net: "caffe_net_with_pooling.prototxt" 2 | test_iter: 10 3 | type: "SGD" 4 | test_interval: 10000 5 | base_lr: 0.03 6 | lr_policy: "step" 7 | gamma: 0.99 8 | stepsize: 5000 9 | display: 1000 10 | max_iter: 300000 11 | momentum: 0.9 12 | weight_decay: 0.00005 13 | snapshot: 50000 14 | snapshot_prefix: "snapshots/" 15 | solver_mode: CPU 16 | -------------------------------------------------------------------------------- /casestudies/MNIST/testAccuracy.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | unset -v latest 3 | for file in "snapshots"/_iter_*.caffemodel; do 4 | [[ $file -nt $latest ]] && latest=$file 5 | done 6 | echo $latest 7 | python ../../tools/caffemodel2json.py $CAFFE/src/caffe/proto/caffe.proto $latest --data > testNetwork.json 8 | ../../tools/json_network_to_rlv_translator.py testNetwork.json > testNetwork.rlv 9 | ./computeMNISTAccuracy.py testNetwork.rlv testing_mnist_png 10 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/run100TimesTrain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # Check how often learning leads to 100% accuracy 3 | import os, sys, subprocess 4 | 5 | for i in range(0,100): 6 | experiment = subprocess.Popen("./train.sh",shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 7 | acc = None 8 | for line in experiment.stdout.readlines(): 9 | if line.find("Test net output #0: accuracy =")!=-1: 10 | acc = line.split(" ")[-1] 11 | with open("poolingAccurracies.txt","a") as outFile: 12 | outFile.write(acc) 13 | 14 | -------------------------------------------------------------------------------- /tools/sumUserTimes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | import os, sys 3 | 4 | for inFile in sys.argv[1:]: 5 | 6 | sumTimes = 0.0 7 | foundAbortString = False 8 | with open(inFile,"r") as inFileReader: 9 | for line in inFileReader.readlines(): 10 | if line.find("user")!=-1: 11 | time = float(line[0:line.find("user")]) 12 | sumTimes += time 13 | if line.find("Command exited with non-zero status 124")!=-1: 14 | foundAbortString = True 15 | 16 | if not foundAbortString: 17 | print str(sumTimes)+"user" 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | matrix: 3 | include: 4 | - compiler: gcc-5 5 | os: linux 6 | sudo: required 7 | dist: trusty 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | - llvm-toolchain-trusty 13 | packages: 14 | - libboost-all-dev 15 | - libglpk-dev 16 | - qt5-qmake 17 | - g++-5 18 | - gcc-5 19 | - clang-3.8 20 | - qt5-default 21 | - valgrind 22 | env: CXX=clang++-3.8 23 | env: CC=clang-3.8 24 | 25 | script: 26 | - cd src 27 | - qmake -spec linux-clang "QMAKE_CXX=clang++-3.8" Tool.pro 28 | - make -j2 29 | - cd ..;cd benchmarks/aFewTests 30 | - ../../tools/testBenchmarksInThisDirectory.py ../../src/planet 31 | -------------------------------------------------------------------------------- /casestudies/MNIST/lenet_solver.prototxt: -------------------------------------------------------------------------------- 1 | # The train/test net protocol buffer definition 2 | net: "lenet_train_test.prototxt" 3 | # test_iter specifies how many forward passes the test should carry out. 4 | # In the case of MNIST, we have test batch size 100 and 100 test iterations, 5 | # covering the full 10,000 testing images. 6 | test_iter: 100 7 | # Carry out testing every 500 training iterations. 8 | test_interval: 1000 9 | # The base learning rate, momentum and the weight decay of the network. 10 | base_lr: 0.01 11 | momentum: 0.9 12 | weight_decay: 0.0005 13 | # The learning rate policy 14 | lr_policy: "inv" 15 | gamma: 0.0001 16 | power: 0.75 17 | # Display every 100 iterations 18 | display: 1000 19 | # The maximum number of iterations 20 | max_iter: 200000 21 | # snapshot intermediate results 22 | snapshot: 100000 23 | snapshot_prefix: "snapshots/" 24 | # solver mode: CPU or GPU 25 | solver_mode: CPU 26 | -------------------------------------------------------------------------------- /tools/pngToTikz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os, glob, sys, subprocess 3 | import PIL.Image 4 | from joblib import Parallel, delayed 5 | 6 | if len(sys.argv)<2: 7 | print >>sys.stderr, "Error: Wanted an PNG filename" 8 | sys.exit(1) 9 | 10 | pngFile = sys.argv[1] 11 | inImage = PIL.Image.open(pngFile) 12 | 13 | print "\\begin{tikzpicture}[xscale=0.09,yscale=-0.09]" 14 | xSize = inImage.width 15 | ySize = inImage.height 16 | for y in range(0,ySize): 17 | for x in range(0,xSize): 18 | print "\\path[fill=black!"+str(inImage.getpixel((x,y))/2.550)+"!white] (",x,",",y,") rectangle +(1,1);" 19 | #for y in range(0,ySize): 20 | # print "\\draw[line width=0.03pt,color=black!10!white] (0,",y,") -- +(",xSize,",0);" 21 | #for x in range(0,xSize): 22 | # print "\\draw[line width=0.03pt,color=black!10!white] (",x,",0) -- +(0,",ySize,");" 23 | 24 | print "\\draw[semithick] (0,0) rectangle (",xSize,",",ySize,");" 25 | print "\\end{tikzpicture}" 26 | 27 | -------------------------------------------------------------------------------- /src/Tool.pro: -------------------------------------------------------------------------------- 1 | QMAKE_CXXFLAGS += -std=c++14 -g 2 | DEFINES += USE_GLPK NDEBUG 3 | 4 | TEMPLATE = app \ 5 | console 6 | CONFIG += release 7 | CONFIG -= app_bundle 8 | CONFIG -= qt 9 | QT -= gui \ 10 | core 11 | 12 | HEADERS += minisat2/Alg.h minisat2/Heap.h minisat2/Map.h minisat2/Queue.h minisat2/SolverTypes.h minisat2/Vec.h minisat2/Alloc.h minisat2/IntMap.h minisat2/Options.h minisat2/Rnd.h minisat2/Sort.h minisat2/XAlloc.h minisat2/Dimacs.h minisat2/IntTypes.h minisat2/ParseUtils.h minisat2/Solver.h minisat2/System.h supersetdatabase.hpp 13 | 14 | HEADERS += verifierContext.hpp lpSolvers.hpp config.h 15 | 16 | SOURCES += minisat2/Options.cc minisat2/Solver.cc minisat2/System.cc main.cpp verifierContext.cpp supersetdatabase.cpp 17 | 18 | TARGET = planet 19 | 20 | INCLUDEPATH += /usr/include/lpsolve/ 21 | 22 | LIBS += -static -lglpk -lgmp -lumfpack -lsuitesparseconfig -lcholmod -lamd -lcolamd -lccolamd -lcamd -lz -lltdl -ldl #-static 23 | 24 | PKGCONFIG += 25 | 26 | -------------------------------------------------------------------------------- /src/minisat2/LICENSE: -------------------------------------------------------------------------------- 1 | MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 2 | Copyright (c) 2007-2010 Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a 5 | copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /tools/makeParallelCheckingOfAllRLVFilesInThisDirectoryMakefile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | # 3 | # Build a makefile for checking many RLV cases in parallel 4 | import os, sys, glob 5 | 6 | if len(sys.argv)<2: 7 | print >>sys.stderr, "Error: Expected the path to the verifier as parameter." 8 | sys.exit(1) 9 | 10 | if len(sys.argv)>3: 11 | print >>sys.stderr, "Error: Too many parameters passed. Expecting the revifier command and optionally a file to check." 12 | sys.exit(1) 13 | 14 | verifier = sys.argv[1] 15 | scriptpath = os.path.dirname(os.path.realpath(__file__)) 16 | 17 | allRLVFiles = list(glob.glob("*.rlv")) 18 | allRLVFiles.sort() 19 | 20 | with open("Makefile","w") as outFile: 21 | outFile.write("default: "+" ".join([".out/"+a+".txt" for a in allRLVFiles])) 22 | outFile.write("\n\t@mkdir -p performanceComparisons\n") 23 | outFile.write("\t@cat .out/*.txt > \"performanceComparisons/`(git show | grep Date)`\"\n\n") 24 | 25 | for a in allRLVFiles: 26 | outFile.write(".out/"+a+".txt:\n") 27 | outFile.write("\t@mkdir -p .out\n") 28 | outFile.write("\t@echo \"Processing: "+a+"\"\n") 29 | outFile.write("\t@(time timeout 3600 "+scriptpath+"/"+"testBenchmarksInThisDirectory.py "+verifier+" "+a+" > .out/"+a+".txt 2>&1) || if [ $$? -eq 124 ]; then echo \"--> "+a+" timed out\"; else false; fi \n\n") 30 | 31 | -------------------------------------------------------------------------------- /src/minisat2/IntTypes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************[IntTypes.h] 2 | Copyright (c) 2009-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef Minisat_IntTypes_h 21 | #define Minisat_IntTypes_h 22 | 23 | #ifdef __sun 24 | // Not sure if there are newer versions that support C99 headers. The 25 | // needed features are implemented in the headers below though: 26 | 27 | # include 28 | # include 29 | # include 30 | 31 | #else 32 | 33 | # include 34 | # include 35 | 36 | #endif 37 | 38 | #include 39 | 40 | //================================================================================================= 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /tools/makeYicesComparisonMakefile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | # 3 | # Build a makefile for checking many RLV cases in parallel 4 | import os, sys, glob 5 | 6 | if len(sys.argv)!=2: 7 | print >>sys.stderr, "Error: Too many or too few parameters passed. Expecting only the parameter to PLANET (--smtlibApprox or --smtlib)" 8 | sys.exit(1) 9 | 10 | scriptpath = os.path.dirname(os.path.realpath(__file__)) 11 | 12 | allRLVFiles = list(glob.glob("*.rlv")) 13 | allRLVFiles.sort() 14 | option = sys.argv[1] 15 | 16 | with open("Makefile","w") as outFile: 17 | outFile.write("default: "+" ".join([".out/"+a+".ytxt" for a in allRLVFiles])) 18 | outFile.write("\n\t@mkdir -p performanceComparisons\n") 19 | outFile.write("\t@cat .out/*.ytxt > \"performanceComparisons/YICES`(git show | grep Date)`\"\n\n") 20 | 21 | for a in allRLVFiles: 22 | outFile.write(".out/"+a+".ytxt:\n") 23 | outFile.write("\t@mkdir -p .out\n") 24 | outFile.write("\t@echo \"Processing: "+a+"\"\n") 25 | outFile.write("\ttime "+scriptpath+"/../src/planet "+option+" "+a+" > .out/"+a+".smt2 2> .out/"+a+".ytxt \n") 26 | outFile.write("\t@echo \"Processing Part 2: "+a+"\"\n") 27 | if sys.argv[1].find("pprox")>0: 28 | outFile.write("\t@(time timeout 3600 $$YICES/bin/yices-smt2 .out/"+a+".smt2 >> .out/"+a+".ytxt 2>&1) || if [ $$? -eq 124 ]; then echo \"--> "+a+" timed out\"; else false; fi\n") 29 | else: 30 | outFile.write("\t@(time timeout 3600 $$YICES/bin/yices-smt2 .out/"+a+".smt2 > .out/"+a+".ytxt 2>&1) || if [ $$? -eq 124 ]; then echo \"--> "+a+" timed out\"; else false; fi\n") 31 | outFile.write("\tcat .out/"+a+".ytxt | grep \"^Command exited with non-zero status 124\\|^") 32 | if a.endswith("_SAT.rlv"): 33 | outFile.write("sat\"\n") 34 | elif a.endswith("_UNSAT.rlv"): 35 | outFile.write("unsat\"\n") 36 | else: 37 | raise "File does not end with _SAT or _UNSAT: "+a 38 | outFile.write("\n\n") 39 | 40 | -------------------------------------------------------------------------------- /src/minisat2/XAlloc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[XAlloc.h] 2 | Copyright (c) 2009-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | 21 | #ifndef Minisat_XAlloc_h 22 | #define Minisat_XAlloc_h 23 | 24 | #include 25 | #include 26 | 27 | namespace Minisat { 28 | 29 | //================================================================================================= 30 | // Simple layer on top of malloc/realloc to catch out-of-memory situtaions and provide some typing: 31 | 32 | class OutOfMemoryException{}; 33 | static inline void* xrealloc(void *ptr, size_t size) 34 | { 35 | void* mem = realloc(ptr, size); 36 | if (mem == NULL && errno == ENOMEM){ 37 | throw OutOfMemoryException(); 38 | }else 39 | return mem; 40 | } 41 | 42 | //================================================================================================= 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /tools/makeGurobiComparisonMakefile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | # 3 | # Build a makefile for checking many RLV cases in parallel 4 | import os, sys, glob 5 | 6 | if len(sys.argv)!=2: 7 | print >>sys.stderr, "Error: Too many or too few parameters passed. Expecting only the parameter to PLANET (--smtlibApprox or --smtlib)" 8 | sys.exit(1) 9 | 10 | scriptpath = os.path.dirname(os.path.realpath(__file__)) 11 | 12 | allRLVFiles = list(glob.glob("*.rlv")) 13 | allRLVFiles.sort() 14 | option = sys.argv[1] 15 | 16 | with open("Makefile","w") as outFile: 17 | outFile.write("default: "+" ".join([".out/"+a+".ytxt" for a in allRLVFiles])) 18 | outFile.write("\n\t@mkdir -p performanceComparisons\n") 19 | outFile.write("\t@../../tools/sumUserTimes.py .out/*.ytxt > \"performanceComparisons/Gurobi"+sys.argv[1]+"\"\n") 20 | 21 | for a in allRLVFiles: 22 | outFile.write(".out/"+a+".ytxt:\n") 23 | outFile.write("\t@mkdir -p .out\n") 24 | outFile.write("\t@echo \"Processing: "+a+"\"\n") 25 | outFile.write("\ttime "+scriptpath+"/../src/planet "+option+" "+a+" > .out/"+a+".ilp 2> .out/"+a+".ytxt \n") 26 | outFile.write("\t@echo \"Processing Part 2: "+a+"\"\n") 27 | if sys.argv[1].find("pprox")>0: 28 | outFile.write("\t@(time timeout 3600 $$GUROBI_HOME/bin/runGurobi.sh .out/"+a+".ilp >> .out/"+a+".ytxt 2>&1) || if [ $$? -eq 124 ]; then echo \"--> "+a+" timed out\"; else false; fi\n") 29 | else: 30 | outFile.write("\t@(time timeout 3600 $$GUROBI_HOME/bin/runGurobi.sh .out/"+a+".ilp > .out/"+a+".ytxt 2>&1) || if [ $$? -eq 124 ]; then echo \"--> "+a+" timed out\"; else false; fi\n") 31 | outFile.write("\tcat .out/"+a+".ytxt | grep \"^Command exited with non-zero status 124\\|^") 32 | if a.endswith("_SAT.rlv"): 33 | outFile.write("Optimal solution found\"\n") 34 | elif a.endswith("_UNSAT.rlv"): 35 | outFile.write("Infeasible model\|^Model is infeasible or unbounded\"\n") 36 | else: 37 | raise "File does not end with _SAT or _UNSAT: "+a 38 | outFile.write("\n\n") 39 | 40 | -------------------------------------------------------------------------------- /src/minisat2/README: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | Quick Install 3 | 4 | - Decide where to install the files . The simplest approach is to use 5 | GNU standard locations and just set a "prefix" for the root install 6 | directory (reffered to as $PREFIX below). More control can be 7 | achieved by overriding other of the GNU standard install locations 8 | (includedir, bindir, etc). Configuring with just a prefix: 9 | 10 | > make config prefix=$PREFIX 11 | 12 | - Compiling and installing: 13 | 14 | > make install 15 | 16 | ================================================================================ 17 | Configuration 18 | 19 | - Multiple configuration steps can be joined into one call to "make 20 | config" by appending multiple variable assignments on the same line. 21 | 22 | - The configuration is stored in the file "config.mk". Look here if 23 | you want to know what the current configuration looks like. 24 | 25 | - To reset from defaults simply remove the "config.mk" file or call 26 | "make distclean". 27 | 28 | - Recompilation can be done without the configuration step. 29 | 30 | [ TODO: describe configartion possibilities for compile flags / modes ] 31 | 32 | ================================================================================ 33 | Building 34 | 35 | [ TODO: describe seperate build modes ] 36 | 37 | ================================================================================ 38 | Install 39 | 40 | [ TODO: ? ] 41 | 42 | ================================================================================ 43 | Directory Overview: 44 | 45 | minisat/mtl/ Mini Template Library 46 | minisat/utils/ Generic helper code (I/O, Parsing, CPU-time, etc) 47 | minisat/core/ A core version of the solver 48 | minisat/simp/ An extended solver with simplification capabilities 49 | doc/ Documentation 50 | README 51 | LICENSE 52 | 53 | ================================================================================ 54 | Examples: 55 | 56 | Run minisat with same heuristics as version 2.0: 57 | 58 | > minisat -no-luby -rinc=1.5 -phase-saving=0 -rnd-freq=0.02 59 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/caffe_net_with_pooling.prototxt: -------------------------------------------------------------------------------- 1 | layer { 2 | name: "data" 3 | type: "HDF5Data" 4 | top: "data" 5 | top: "classes" 6 | hdf5_data_param { 7 | source: "train_data_list.txt" 8 | batch_size: 128 9 | } 10 | } 11 | layer { 12 | name: "ip1" 13 | type: "InnerProduct" 14 | bottom: "data" 15 | top: "ip1" 16 | inner_product_param { 17 | num_output: 40 18 | weight_filler { 19 | type: "xavier" 20 | } 21 | } 22 | } 23 | layer { 24 | name: "relu1" 25 | type: "ReLU" 26 | bottom: "ip1" 27 | top: "relu1" 28 | } 29 | 30 | layer { 31 | name: "reshapeA" 32 | type: "Reshape" 33 | bottom: "relu1" 34 | top: "reshapeA" 35 | reshape_param { 36 | shape { 37 | dim: -1 # copy the dimension from below 38 | dim: 1 # copy the dimension from below 39 | dim: 20 # copy the dimension from below 40 | dim: 2 # infer it from the other dimensions 41 | } 42 | } 43 | } 44 | 45 | layer { 46 | name: "pool1" 47 | type: "Pooling" 48 | bottom: "reshapeA" 49 | top: "pool1" 50 | pooling_param { 51 | pool: MAX 52 | kernel_size: 2 # pool over a 3x3 region 53 | } 54 | } 55 | 56 | layer { 57 | name: "reshapeB" 58 | type: "Reshape" 59 | bottom: "pool1" 60 | top: "reshapeB" 61 | reshape_param { 62 | shape { 63 | dim: -1 64 | dim: 19 # infer it from the other dimensions 65 | } 66 | } 67 | } 68 | 69 | layer { 70 | name: "ipA" 71 | type: "InnerProduct" 72 | bottom: "reshapeB" 73 | top: "ipA" 74 | inner_product_param { 75 | num_output: 19 76 | weight_filler { 77 | type: "xavier" 78 | } 79 | } 80 | } 81 | layer { 82 | name: "relu2" 83 | type: "ReLU" 84 | bottom: "ipA" 85 | top: "relu2" 86 | } 87 | layer { 88 | name: "ip2" 89 | type: "InnerProduct" 90 | bottom: "relu2" 91 | top: "ip2" 92 | inner_product_param { 93 | num_output: 2 94 | weight_filler { 95 | type: "xavier" 96 | } 97 | } 98 | } 99 | layer { 100 | name: "accuracy" 101 | type: "Accuracy" 102 | bottom: "ip2" 103 | bottom: "classes" 104 | top: "accuracy" 105 | } 106 | layer { 107 | name: "loss" 108 | type: "SoftmaxWithLoss" 109 | bottom: "ip2" 110 | bottom: "classes" 111 | top: "loss" 112 | } 113 | -------------------------------------------------------------------------------- /src/minisat2/Rnd.h: -------------------------------------------------------------------------------- 1 | /*******************************************************************************************[Rnd.h] 2 | Copyright (c) 2012, Niklas Sorensson 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 4 | associated documentation files (the "Software"), to deal in the Software without restriction, 5 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or 10 | substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 13 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 16 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | **************************************************************************************************/ 18 | 19 | #ifndef Minisat_Rnd_h 20 | #define Minisat_Rnd_h 21 | 22 | #include "Vec.h" 23 | 24 | namespace Minisat { 25 | 26 | // Generate a random double: 27 | static inline double drand(double& seed) 28 | { 29 | seed *= 1389796; 30 | int q = (int)(seed / 2147483647); 31 | seed -= (double)q * 2147483647; 32 | return seed / 2147483647; 33 | } 34 | 35 | 36 | // Generate a random integer: 37 | static inline int irand(double& seed, int size) { return (int)(drand(seed) * size); } 38 | 39 | 40 | // Randomly shuffle the contents of a vector: 41 | template 42 | static void randomShuffle(double& seed, vec& xs) 43 | { 44 | for (int i = 0; i < xs.size(); i++){ 45 | int pick = i + irand(seed, xs.size() - i); 46 | T tmp = xs[i]; 47 | xs[i] = xs[pick]; 48 | xs[pick] = tmp; 49 | } 50 | } 51 | 52 | // Randomly shuffle a vector of a vector (ugly) 53 | template 54 | static void randomShuffle(double& seed, vec >& xs) 55 | { 56 | for (int i = 0; i < xs.size(); i++){ 57 | int pick = i + irand(seed, xs.size() - i); 58 | vec tmp; xs[i].moveTo(tmp); 59 | xs[pick].moveTo(xs[i]); 60 | tmp.moveTo(xs[pick]); 61 | } 62 | } 63 | 64 | 65 | //================================================================================================= 66 | } // namespace Minisat 67 | #endif 68 | -------------------------------------------------------------------------------- /tools/testBenchmarksInThisDirectory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os, glob, sys, subprocess 3 | 4 | if len(sys.argv)<2: 5 | print >>sys.stderr, "Error: Expected the path to the verifier as parameter." 6 | sys.exit(1) 7 | 8 | if len(sys.argv)>3: 9 | print >>sys.stderr, "Error: Too many parameters passed. Expecting the revifier command and optionally a file to check." 10 | sys.exit(1) 11 | 12 | verifier = sys.argv[1] 13 | 14 | if len(sys.argv)==3: 15 | allRLVFiles = list(glob.glob(sys.argv[2])) 16 | else: 17 | allRLVFiles = list(glob.glob("*.rlv")) 18 | allRLVFiles.sort() 19 | 20 | # Find RELUV binary 21 | location = sys.argv[0] 22 | while location[-1]!="/" and len(location)>0: 23 | location = location[0:len(location)-1] 24 | 25 | # Iterate over the benchmarks 26 | for benchmark in allRLVFiles: 27 | assert benchmark.endswith(".rlv") 28 | sys.stdout.write(benchmark) 29 | sys.stdout.flush() 30 | benchmarkMainPart = benchmark[0:len(benchmark)-4] 31 | 32 | # Run RLV 33 | process = subprocess.Popen([verifier,benchmark],stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 34 | resultFound = False 35 | result = None 36 | totalErrorLine = None 37 | otherLines = [] 38 | for line in process.stdout.readlines(): 39 | otherLines.append(line) 40 | line = line + "\n" 41 | if line.startswith("SAT\n"): 42 | resultFound = True 43 | result = True 44 | elif line.startswith("UNSAT\n"): 45 | resultFound = True 46 | result = False 47 | elif line.startswith("Total error:"): 48 | totalErrorLine = line.strip() 49 | errorCode = process.wait() 50 | if errorCode!=0: 51 | print >>sys.stderr, "Error running "+verifier+" "+benchmark+ " -- Error Code:",errorCode 52 | print >>sys.stderr, "Output:\n"+"".join(otherLines) 53 | print >>sys.stderr, "That was an error running "+verifier+" "+benchmark+ " -- Error Code:",errorCode 54 | sys.exit(1) 55 | 56 | if not resultFound: 57 | print >>sys.stderr, "Error: No result for "+benchmark+" found." 58 | sys.exit(1) 59 | 60 | if benchmarkMainPart.endswith("_SAT"): 61 | if not result: 62 | print >>sys.stderr, "Error: Differing results for "+benchmark+" found." 63 | sys.exit(1) 64 | elif benchmarkMainPart.endswith("_UNSAT"): 65 | if result: 66 | print >>sys.stderr, "Error: Differing results for "+benchmark+" found." 67 | sys.exit(1) 68 | else: 69 | print "Note: No expected result for "+benchmark+" found." 70 | 71 | print " -> OK." 72 | if totalErrorLine!=None: 73 | print totalErrorLine 74 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "verifierContext.hpp" 2 | #include 3 | 4 | void printSMTLibInstance(bool includingApproximationConstraints); 5 | 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | try { 10 | VerificationProblem problem; 11 | int printSMTLibInstance = 0; 12 | int printILPInstance = 0; 13 | std::string inFileName = ""; 14 | for (unsigned int i=1;i(argc);i++) { 15 | if (std::string(argv[i]).substr(0,1)=="-") { 16 | // Parameters 17 | if (std::string(argv[i])=="--smtlib") { 18 | printSMTLibInstance = 1; 19 | } else if (std::string(argv[i])=="--smtlibApprox") { 20 | printSMTLibInstance = 2; 21 | } else if (std::string(argv[i])=="--ilp") { 22 | printILPInstance = 1; 23 | } else if (std::string(argv[i])=="--ilpApprox") { 24 | printILPInstance = 2; 25 | } else { 26 | std::cerr << "Error: Did not understand parameter '" << argv[i] << "'\n"; 27 | return 1; 28 | } 29 | } else { 30 | if (inFileName=="") { 31 | inFileName = argv[i]; 32 | } else { 33 | throw "Error: More than one file name given."; 34 | } 35 | } 36 | } 37 | problem.load(inFileName); 38 | 39 | if (printSMTLibInstance==1) { // No Approx 40 | problem.printSMTLibInstance(false); 41 | } else if (printILPInstance==1) { 42 | problem.printILPInstance(false); 43 | } else { 44 | if (!(problem.computeInitialNeuronLimitBounds())) { 45 | if (printSMTLibInstance>0) 46 | std::cout << "(set-logic QF_LRA) (declare-fun a () Bool) (assert a) (assert (not a)) (check-sat)\n"; 47 | else if (printILPInstance>0) 48 | std::cout << "Subject To\n x <= 0\n x >= 1\nEnd\n"; 49 | else 50 | std::cout << "UNSAT\n"; 51 | 52 | } else { 53 | if (printILPInstance>0) { 54 | problem.printILPInstance(true); 55 | } else if (printSMTLibInstance>0) { 56 | problem.printSMTLibInstance(true); 57 | } else { 58 | problem.verify(); 59 | } 60 | } 61 | } 62 | 63 | } catch (const char *c) { 64 | std::cerr << "Error: " << c << std::endl; 65 | return 1; 66 | } catch (std::string c) { 67 | std::cerr << "Error: " << c << std::endl; 68 | return 1; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/minisat2/Alg.h: -------------------------------------------------------------------------------- 1 | /*******************************************************************************************[Alg.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_Alg_h 22 | #define Minisat_Alg_h 23 | 24 | #include "Vec.h" 25 | 26 | namespace Minisat { 27 | 28 | //================================================================================================= 29 | // Useful functions on vector-like types: 30 | 31 | //================================================================================================= 32 | // Removing and searching for elements: 33 | // 34 | 35 | template 36 | static inline void remove(V& ts, const T& t) 37 | { 38 | int j = 0; 39 | for (; j < (int)ts.size() && ts[j] != t; j++); 40 | assert(j < (int)ts.size()); 41 | for (; j < (int)ts.size()-1; j++) ts[j] = ts[j+1]; 42 | ts.pop(); 43 | } 44 | 45 | 46 | template 47 | static inline bool find(V& ts, const T& t) 48 | { 49 | int j = 0; 50 | for (; j < (int)ts.size() && ts[j] != t; j++); 51 | return j < (int)ts.size(); 52 | } 53 | 54 | 55 | //================================================================================================= 56 | // Copying vectors with support for nested vector types: 57 | // 58 | 59 | // Base case: 60 | template 61 | static inline void copy(const T& from, T& to) 62 | { 63 | to = from; 64 | } 65 | 66 | // Recursive case: 67 | template 68 | static inline void copy(const vec& from, vec& to, bool append = false) 69 | { 70 | if (!append) 71 | to.clear(); 72 | for (int i = 0; i < from.size(); i++){ 73 | to.push(); 74 | copy(from[i], to.last()); 75 | } 76 | } 77 | 78 | template 79 | static inline void append(const vec& from, vec& to){ copy(from, to, true); } 80 | 81 | //================================================================================================= 82 | } 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /casestudies/MNIST/lenet_train_test.prototxt: -------------------------------------------------------------------------------- 1 | name: "LeNet" 2 | layer { 3 | name: "mnist" 4 | type: "Data" 5 | top: "data" 6 | top: "label" 7 | include { 8 | phase: TRAIN 9 | } 10 | transform_param { 11 | scale: 0.00390625 12 | } 13 | data_param { 14 | source: "mnist_train_lmdb" 15 | batch_size: 64 16 | backend: LMDB 17 | } 18 | } 19 | layer { 20 | name: "mnist" 21 | type: "Data" 22 | top: "data" 23 | top: "label" 24 | include { 25 | phase: TEST 26 | } 27 | transform_param { 28 | scale: 0.00390625 29 | } 30 | data_param { 31 | source: "mnist_test_lmdb" 32 | batch_size: 100 33 | backend: LMDB 34 | } 35 | } 36 | 37 | layer { 38 | name: "reshapeA" 39 | type: "Reshape" 40 | bottom: "data" 41 | top: "reshapeA" 42 | reshape_param { 43 | shape { 44 | dim: -1 # copy the dimension from below 45 | dim: 1 # copy the dimension from below 46 | dim: 28 # copy the dimension from below 47 | dim: 28 # infer it from the other dimensions 48 | } 49 | } 50 | } 51 | 52 | layer { 53 | name: "conv1" 54 | type: "Convolution" 55 | bottom: "reshapeA" 56 | top: "conv1" 57 | param { 58 | lr_mult: 1 59 | } 60 | param { 61 | lr_mult: 2 62 | } 63 | convolution_param { 64 | num_output: 3 65 | kernel_size: 4 66 | stride: 2 67 | weight_filler { 68 | type: "xavier" 69 | } 70 | bias_filler { 71 | type: "constant" 72 | } 73 | } 74 | } 75 | layer { 76 | name: "pool1" 77 | type: "Pooling" 78 | bottom: "conv1" 79 | top: "pool1" 80 | pooling_param { 81 | pool: MAX 82 | kernel_size: 4 83 | stride: 3 84 | } 85 | } 86 | 87 | layer { 88 | name: "reshapeB" 89 | type: "Reshape" 90 | bottom: "pool1" 91 | top: "reshapeB" 92 | reshape_param { 93 | shape { 94 | dim: -1 # copy the dimension from below 95 | dim: 48 # infer it from the other dimensions 96 | } 97 | } 98 | } 99 | 100 | layer { 101 | name: "ip1" 102 | type: "InnerProduct" 103 | bottom: "reshapeB" 104 | top: "ip1" 105 | param { 106 | lr_mult: 1 107 | } 108 | param { 109 | lr_mult: 2 110 | } 111 | inner_product_param { 112 | num_output: 8 113 | weight_filler { 114 | type: "xavier" 115 | } 116 | bias_filler { 117 | type: "constant" 118 | } 119 | } 120 | } 121 | layer { 122 | name: "relu1" 123 | type: "ReLU" 124 | bottom: "ip1" 125 | top: "relu1" 126 | } 127 | layer { 128 | name: "ip2" 129 | type: "InnerProduct" 130 | bottom: "relu1" 131 | top: "ip2" 132 | param { 133 | lr_mult: 1 134 | } 135 | param { 136 | lr_mult: 2 137 | } 138 | inner_product_param { 139 | num_output: 10 140 | weight_filler { 141 | type: "xavier" 142 | } 143 | bias_filler { 144 | type: "constant" 145 | } 146 | } 147 | } 148 | layer { 149 | name: "accuracy" 150 | type: "Accuracy" 151 | bottom: "ip2" 152 | bottom: "label" 153 | top: "accuracy" 154 | } 155 | layer { 156 | name: "loss" 157 | type: "SoftmaxWithLoss" 158 | bottom: "ip2" 159 | bottom: "label" 160 | top: "loss" 161 | } 162 | -------------------------------------------------------------------------------- /src/minisat2/Queue.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************************[Queue.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_Queue_h 22 | #define Minisat_Queue_h 23 | 24 | #include "Vec.h" 25 | 26 | namespace Minisat { 27 | 28 | //================================================================================================= 29 | 30 | template 31 | class Queue { 32 | vec buf; 33 | int first; 34 | int end; 35 | 36 | public: 37 | typedef T Key; 38 | 39 | Queue() : buf(1), first(0), end(0) {} 40 | 41 | void clear (bool dealloc = false) { buf.clear(dealloc); buf.growTo(1); first = end = 0; } 42 | int size () const { return (end >= first) ? end - first : end - first + buf.size(); } 43 | 44 | const T& operator [] (int index) const { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; } 45 | T& operator [] (int index) { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; } 46 | 47 | T peek () const { assert(first != end); return buf[first]; } 48 | void pop () { assert(first != end); first++; if (first == buf.size()) first = 0; } 49 | void insert(T elem) { // INVARIANT: buf[end] is always unused 50 | buf[end++] = elem; 51 | if (end == buf.size()) end = 0; 52 | if (first == end){ // Resize: 53 | vec tmp((buf.size()*3 + 1) >> 1); 54 | //**/printf("queue alloc: %d elems (%.1f MB)\n", tmp.size(), tmp.size() * sizeof(T) / 1000000.0); 55 | int i = 0; 56 | for (int j = first; j < buf.size(); j++) tmp[i++] = buf[j]; 57 | for (int j = 0 ; j < end ; j++) tmp[i++] = buf[j]; 58 | first = 0; 59 | end = buf.size(); 60 | tmp.moveTo(buf); 61 | } 62 | } 63 | }; 64 | 65 | 66 | //================================================================================================= 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /casestudies/MNIST/computeMNISTAccuracy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os, glob, sys, subprocess 3 | import PIL.Image 4 | from joblib import Parallel, delayed 5 | 6 | if len(sys.argv)<3: 7 | print >>sys.stderr, "Error: Wanted an RLV filename (output by json_network_to_rlv_translator) and a path with the testing PNG images" 8 | sys.exit(1) 9 | 10 | rlvFile = sys.argv[1] 11 | testingDir = sys.argv[2] 12 | 13 | # Read RLV Lines 14 | with open(rlvFile,"r") as inRLV: 15 | rlvLines = inRLV.readlines() 16 | 17 | # Iterate over digits 18 | correct = 0 19 | total = 0 20 | 21 | for digit in range(0,10): 22 | print "\nDigit: ",digit 23 | allPngFiles = glob.glob(testingDir+"/"+str(digit)+"/*.png") 24 | 25 | def workOnPNG(pngFile): 26 | im = PIL.Image.open(pngFile) #Can be many different formats. 27 | pix = im.load() 28 | assert im.size==(28,28) 29 | pixels = [pix[x,y] for y in range(0,28) for x in range(0,28)] 30 | 31 | # Open RELU-Verifier 32 | verifierProcess = subprocess.Popen("../ReLUVerifier/src2/reluv2 /dev/stdin",shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 33 | # outtaFile = open("/tmp/iniCheck.rlv","w") 34 | for a in rlvLines: 35 | verifierProcess.stdin.write(a) 36 | # outtaFile.write(a) 37 | for i in range(0,len(pixels)): 38 | pixelValue = pixels[i]/256.0 39 | verifierProcess.stdin.write("Assert <= "+str(pixelValue-0.0001)+" "+"1.0 inX"+str(i)+"\n") 40 | verifierProcess.stdin.write("Assert >= "+str(pixelValue+0.0001)+" "+"1.0 inX"+str(i)+"\n") 41 | # outtaFile.write("Assert <= "+str(pixelValue)+" "+"1.0 inX"+str(i)+"\n") 42 | # outtaFile.write("Assert >= "+str(pixelValue)+" "+"1.0 inX"+str(i)+"\n") 43 | verifierProcess.stdin.close() 44 | # outtaFile.close() 45 | 46 | foundSATLine = False 47 | foundValuationLine = False 48 | values = {} 49 | for a in verifierProcess.stdout.readlines(): 50 | a = a.strip() 51 | if a=="SAT": 52 | foundSATLine = True 53 | elif a=="Valuation:": 54 | foundValuationLine = True 55 | elif a.startswith("- ") and foundValuationLine: 56 | parts = a.split(" ") 57 | assert parts[0]=="-" 58 | assert parts[3]=="/" 59 | values[parts[1][0:len(parts[1])-1]] = float(parts[2]) 60 | 61 | assert verifierProcess.wait()==0 62 | assert foundSATLine==True 63 | 64 | bestDigit = -1 65 | bestValue = None 66 | for i in range(0,10): 67 | if (bestValue==None) or values["outX"+str(i)]>bestValue: 68 | bestValue = values["outX"+str(i)] 69 | bestDigit = i 70 | 71 | sys.stdout.write(str(bestDigit)+",") 72 | sys.stdout.flush() 73 | return bestDigit 74 | 75 | allResults = Parallel(n_jobs=4, backend="threading")(delayed(workOnPNG)(a) for a in allPngFiles) 76 | total += len(allResults) 77 | for a in allResults: 78 | if a==digit: 79 | correct += 1 80 | 81 | print "Correct were ", correct, "out of", total 82 | -------------------------------------------------------------------------------- /src/minisat2/System.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[System.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_System_h 22 | #define Minisat_System_h 23 | 24 | #if defined(__linux__) 25 | #include 26 | #endif 27 | 28 | #include "IntTypes.h" 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | 32 | namespace Minisat { 33 | 34 | static inline double cpuTime(void); // CPU-time in seconds. 35 | 36 | extern double memUsed(); // Memory in mega bytes (returns 0 for unsupported architectures). 37 | extern double memUsedPeak(bool strictlyPeak = false); // Peak-memory in mega bytes (returns 0 for unsupported architectures). 38 | 39 | extern void setX86FPUPrecision(); // Make sure double's are represented with the same precision 40 | // in memory and registers. 41 | 42 | extern void limitMemory(uint64_t max_mem_mb); // Set a limit on total memory usage. The exact 43 | // semantics varies depending on architecture. 44 | 45 | extern void limitTime(uint32_t max_cpu_time); // Set a limit on maximum CPU time. The exact 46 | // semantics varies depending on architecture. 47 | 48 | extern void sigTerm(void handler(int)); // Set up handling of available termination signals. 49 | 50 | } 51 | 52 | //------------------------------------------------------------------------------------------------- 53 | // Implementation of inline functions: 54 | 55 | #if defined(_MSC_VER) || defined(__MINGW32__) 56 | #include 57 | 58 | static inline double Minisat::cpuTime(void) { return (double)clock() / CLOCKS_PER_SEC; } 59 | 60 | #else 61 | #include 62 | #include 63 | #include 64 | 65 | static inline double Minisat::cpuTime(void) { 66 | struct rusage ru; 67 | getrusage(RUSAGE_SELF, &ru); 68 | return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; } 69 | 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/supersetdatabase.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SUPERSETDATABASE_HPP__ 2 | #define __SUPERSETDATABASE_HPP__ 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief A special database class that stores subsets of {0, ..., n} for some a-priori defined number n. 9 | * The main query for this database is to slowly add numbers from {0, ..., n} to a trace, and to always return 10 | * whether the database (still) contains a superset. Traces are like stacks -- only the respective last element 11 | * can be removed. 12 | * 13 | * Adding elements can only be done if for the current trace there is no match. 14 | */ 15 | class SupersetDatabase { 16 | private: 17 | std::vector setsInDatabase; // The first element of every int* is the number of elements 18 | int nofObjects; 19 | unsigned int currentSetPointer; 20 | int *trace; 21 | unsigned int *traceDatabasePointers; 22 | unsigned int nofElementsInTrace; 23 | public: 24 | SupersetDatabase(int _nofObjects) : nofObjects(_nofObjects), currentSetPointer(0),nofElementsInTrace(0) { 25 | trace = new int[_nofObjects]; 26 | traceDatabasePointers = new unsigned int[_nofObjects]; 27 | } 28 | ~SupersetDatabase() { 29 | for (auto it : setsInDatabase) delete[] it; 30 | delete[] traceDatabasePointers; 31 | delete[] trace; 32 | } 33 | 34 | // Copy constructor - Not actually quick, as it rebuilds the trace here. 35 | SupersetDatabase(const SupersetDatabase &other) { 36 | nofObjects = other.nofObjects; 37 | trace = new int[nofObjects]; 38 | traceDatabasePointers = new unsigned int[nofObjects]; 39 | setsInDatabase.resize(other.setsInDatabase.size()); 40 | for (unsigned int i=0;i const &elements); 75 | bool addTraceElement(int element); 76 | int removeElementFromTrace(); 77 | void resetTrace(); 78 | 79 | }; 80 | 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/minisat2/Dimacs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[Dimacs.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_Dimacs_h 22 | #define Minisat_Dimacs_h 23 | 24 | #include 25 | 26 | #include "ParseUtils.h" 27 | #include "SolverTypes.h" 28 | 29 | namespace Minisat { 30 | 31 | //================================================================================================= 32 | // DIMACS Parser: 33 | 34 | template 35 | static void readClause(B& in, Solver& S, vec& lits) { 36 | int parsed_lit, var; 37 | lits.clear(); 38 | for (;;){ 39 | parsed_lit = parseInt(in); 40 | if (parsed_lit == 0) break; 41 | var = abs(parsed_lit)-1; 42 | while (var >= S.nVars()) S.newVar(); 43 | lits.push( (parsed_lit > 0) ? mkLit(var) : ~mkLit(var) ); 44 | } 45 | } 46 | 47 | template 48 | static void parse_DIMACS_main(B& in, Solver& S, bool strictp = false) { 49 | vec lits; 50 | int vars = 0; 51 | int clauses = 0; 52 | int cnt = 0; 53 | for (;;){ 54 | skipWhitespace(in); 55 | if (*in == EOF) break; 56 | else if (*in == 'p'){ 57 | if (eagerMatch(in, "p cnf")){ 58 | vars = parseInt(in); 59 | clauses = parseInt(in); 60 | // SATRACE'06 hack 61 | // if (clauses > 4000000) 62 | // S.eliminate(true); 63 | }else{ 64 | printf("PARSE ERROR! Unexpected char: %c\n", *in), exit(3); 65 | } 66 | } else if (*in == 'c' || *in == 'p') 67 | skipLine(in); 68 | else{ 69 | cnt++; 70 | readClause(in, S, lits); 71 | S.addClause_(lits); } 72 | } 73 | if (strictp && cnt != clauses) 74 | printf("PARSE ERROR! DIMACS header mismatch: wrong number of clauses\n"); 75 | } 76 | 77 | // Inserts problem into solver. 78 | // 79 | template 80 | static void parse_DIMACS(gzFile input_stream, Solver& S, bool strictp = false) { 81 | StreamBuffer in(input_stream); 82 | parse_DIMACS_main(in, S, strictp); } 83 | 84 | //================================================================================================= 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /tools/rlvCompressor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # 3 | # Compresses an input RLV (ReLU Verifier) instance in the sense that 4 | # superfluous linear nodes (that are only input to one ReLU node with weight 1) 5 | # are removed (by merging them into the ReLu node). 6 | # 7 | # This makes LP solving a bit easier (due to the variable number reduction) and speeds up the whole process. 8 | # 9 | # TODO: FLOATS need to be printed with maximal precision 10 | import os, sys 11 | 12 | if len(sys.argv)<2: 13 | print >>sys.stderr, "Error: Expected input file" 14 | sys.exit(1) 15 | 16 | with open(sys.argv[1],"r") as inputFile: 17 | inputFileLines = [a.strip() for a in inputFile.readlines()] 18 | 19 | 20 | # While linear nodes are there? 21 | linearNodes = set([]) 22 | linearDefinitionLines = {} 23 | for line in inputFileLines: 24 | line = line.split(" ") 25 | if line[0]=="Linear": 26 | linearNodes.add(line[1]) 27 | linearDefinitionLines[line[1]] = (float(line[2]),line[3:]) 28 | 29 | # Which linear nodes are used outside of ReLUs with Weight 1? 30 | linearNontriviallyUsedNodes = set([]) 31 | for line in inputFileLines: 32 | line = line.split(" ") 33 | if line[1].startswith("outX"): 34 | for i,a in enumerate(line): 35 | if a in linearNodes: 36 | linearNontriviallyUsedNodes.add(a) 37 | if line[0]=="MaxPool": 38 | for i,a in enumerate(line): 39 | if (i>1) and (a in linearNodes): 40 | linearNontriviallyUsedNodes.add(a) 41 | else: 42 | for i,a in enumerate(line): 43 | if (i>1) and (a in linearNodes): 44 | value = float(line[i-1]) 45 | if value!=1.0 or line[0]!="ReLU": 46 | linearNontriviallyUsedNodes.add(a) 47 | 48 | # Now output the new instance, shortened by all Linear nodes that are pushed into ReLUs 49 | for line in inputFileLines: 50 | line = line.split(" ") 51 | if line[0]=="Linear": 52 | if line[1] in linearNontriviallyUsedNodes: 53 | print " ".join(line) 54 | else: 55 | # Remove this one! 56 | pass 57 | elif line[0]=="ReLU": 58 | # Build the new line 59 | constantValue = float(line[2]) 60 | monomials = {} 61 | for i in range(3,len(line),2): 62 | factor = float(line[i]) 63 | variable = line[i+1] 64 | if (variable in linearNodes) and not (variable in linearNontriviallyUsedNodes): 65 | # Add the ReLU inputs 66 | (addedConstant,addedMonomials) = linearDefinitionLines[variable] 67 | constantValue += addedConstant 68 | for j in range(0,len(addedMonomials),2): 69 | if addedMonomials[j+1] in monomials: 70 | monomials[addedMonomials[j+1]] += float(addedMonomials[j]) 71 | else: 72 | monomials[addedMonomials[j+1]] = float(addedMonomials[j]) 73 | else: 74 | if variable in monomials: 75 | monomials[variable] += float(factor) 76 | else: 77 | monomials[variable] = float(factor) 78 | print line[0]+" "+line[1]+" "+str(constantValue)+" "+" ".join([str(b)+" "+a for (a,b) in monomials.iteritems()]) 79 | elif line[0]=="Assert" or line[0]=="Input" or line[0]=="MaxPool": 80 | print " ".join(line) 81 | else: 82 | print >>sys.stderr, "Error: Unknown line type: "+line[0] 83 | sys.exit(1) 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/supersetdatabase.cpp: -------------------------------------------------------------------------------- 1 | #include "supersetdatabase.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | void SupersetDatabase::addSet(std::vector const &elements) { 7 | int *cpy = new int[elements.size()+1]; 8 | for (unsigned int i=0;itrace) && (backPtrSetInDB>currentPtr)) { 23 | int diff = (*backPtrSetInDB); 24 | diff -= *backPtrInTrace; 25 | if (diff==0) { 26 | backPtrSetInDB--; 27 | backPtrInTrace--; 28 | } else if (diff<0) { 29 | backPtrSetInDB = currentPtr; 30 | } else { 31 | backPtrSetInDB--; 32 | } 33 | } 34 | 35 | if (backPtrInTrace=setsInDatabase.size()) return false; 47 | 48 | // Case 2: The current pointer is valid! Then check if the current set also contains this element. 49 | int *currentPtr = setsInDatabase[currentSetPointer]; 50 | int currentSize = currentPtr[0]; 51 | if (std::binary_search(currentPtr+1,currentPtr+currentSize+1,element)) return true; 52 | 53 | // Case 3: We have to search for another set containing all other elements 54 | std::vector sortedElementsInTrace(nofElementsInTrace); 55 | for (unsigned int i=0;i=sortedElementsInTrace.data()) && (backPtrSetInDB>currentPtr)) { 67 | int diff = (*backPtrSetInDB) - *backPtrInTrace; 68 | if (diff==0) { 69 | backPtrSetInDB--; 70 | backPtrInTrace--; 71 | } else if (diff<0) { 72 | backPtrSetInDB = currentPtr; 73 | } else { 74 | backPtrSetInDB--; 75 | } 76 | } 77 | 78 | if (backPtrInTrace 33 | struct LessThan_default { 34 | bool operator () (T x, T y) { return x < y; } 35 | }; 36 | 37 | 38 | template 39 | void selectionSort(T* array, int size, LessThan lt) 40 | { 41 | int i, j, best_i; 42 | T tmp; 43 | 44 | for (i = 0; i < size-1; i++){ 45 | best_i = i; 46 | for (j = i+1; j < size; j++){ 47 | if (lt(array[j], array[best_i])) 48 | best_i = j; 49 | } 50 | tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp; 51 | } 52 | } 53 | template static inline void selectionSort(T* array, int size) { 54 | selectionSort(array, size, LessThan_default()); } 55 | 56 | template 57 | void sort(T* array, int size, LessThan lt) 58 | { 59 | if (size <= 15) 60 | selectionSort(array, size, lt); 61 | 62 | else{ 63 | T pivot = array[size / 2]; 64 | T tmp; 65 | int i = -1; 66 | int j = size; 67 | 68 | for(;;){ 69 | do i++; while(lt(array[i], pivot)); 70 | do j--; while(lt(pivot, array[j])); 71 | 72 | if (i >= j) break; 73 | 74 | tmp = array[i]; array[i] = array[j]; array[j] = tmp; 75 | } 76 | 77 | sort(array , i , lt); 78 | sort(&array[i], size-i, lt); 79 | } 80 | } 81 | template static inline void sort(T* array, int size) { 82 | sort(array, size, LessThan_default()); } 83 | 84 | 85 | //================================================================================================= 86 | // For 'vec's: 87 | 88 | 89 | template void sort(vec& v, LessThan lt) { 90 | sort((T*)v, v.size(), lt); } 91 | template void sort(vec& v) { 92 | sort(v, LessThan_default()); } 93 | 94 | 95 | //================================================================================================= 96 | } 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /tools/drawCactusPlotsForAllPerformanceSummariesInTheCurrentDirectory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os, glob, sys, math 3 | 4 | # Settings 5 | # 6 | PAINTSTYLES = ["color=blue,thick","color=black!50!white,thick","color=red,dashed,thick","color=green!70!black,dotted,thick","color=yellow!60!black","color=red!50!blue","color=green!50!blue","color=green!50!red,thick","color=brown,thick"] 7 | WIDTH = 17 8 | HEIGHT = 8 9 | MAX_TIME = 3600 10 | OVERSHOOT=0.2 11 | NOF_FILES_TICK = 50 12 | MIN_TIME = 0.1 13 | TIME_AXIS_MARKS = [0.1,1,5,10,100,600,1200,3600] 14 | 15 | # Time axis computation 16 | def timeToXCoordinate(time): 17 | time = max(time,MIN_TIME) 18 | return WIDTH*(math.log(time)-math.log(MIN_TIME)) / (math.log(MAX_TIME)-math.log(MIN_TIME)) 19 | 20 | # List Performance Files 21 | performanceFiles = glob.glob("*") 22 | performanceFiles = [a for a in performanceFiles if a.find(".")==-1] 23 | performanceFiles.sort() 24 | totalNofFiles = len(glob.glob("../*.rlv")) 25 | 26 | # Read Performance Files 27 | performances = {} 28 | for inFile in performanceFiles: 29 | 30 | times = [] 31 | 32 | with open(inFile,"r") as inFileReader: 33 | for line in inFileReader.readlines(): 34 | if line.find("user")!=-1: 35 | time = float(line[0:line.find("user")]) 36 | times.append(time) 37 | 38 | performances[inFile] = times 39 | 40 | # Write cactus plot 41 | with open("summary.tex","w") as outFile: 42 | print >>outFile,"\\documentclass[a4paper]{scrartcl}" 43 | print >>outFile,"\\usepackage{tikz}" 44 | print >>outFile,"\\usepackage[left=1cm,right=1cm,top=2cm,bottom=2cm]{geometry}" 45 | print >>outFile,"\\title{Version comparison of reluv2}" 46 | print >>outFile,"\\begin{document}" 47 | print >>outFile,"\\maketitle" 48 | 49 | # Print legend 50 | print >>outFile,"\\subsection*{Legend}" 51 | print >>outFile,"\\begin{tikzpicture}" 52 | for i, a in enumerate(performances): 53 | print >>outFile, "\\draw["+PAINTSTYLES[i]+"] (0,",i*0.8,") -- +(2,0) node[anchor=west,color=black] {"+a+"};" 54 | print >>outFile,"\\end{tikzpicture}" 55 | 56 | # Print cactus plot 57 | print >>outFile,"\\subsection*{Cactus plot}" 58 | print >>outFile,"\\centering\\begin{tikzpicture}[scale=0.4]" 59 | # -> Boundary lines 60 | print >>outFile,"\\draw[very thick,->] (0,0) -- (",WIDTH+OVERSHOOT,",0) node[anchor=west] {Time};" 61 | print >>outFile,"\\draw[very thick,->] (0,0) -- (0,",HEIGHT+OVERSHOOT,") node[anchor=south] {Files};" 62 | print >>outFile,"\\draw[dashed] (",WIDTH,",0) -- +(0,",HEIGHT,");" 63 | print >>outFile,"\\draw[dashed] (0,",HEIGHT,") -- +(",WIDTH,",0);" 64 | # -> Nof files tick 65 | for i in range(NOF_FILES_TICK,totalNofFiles+1,NOF_FILES_TICK): 66 | pos = (HEIGHT/float(totalNofFiles))*i 67 | print >>outFile,"\\draw[semithick] (0.1,",pos,") -- +(-0.2,0) node[anchor=east] {\small "+str(i)+"};" 68 | # -> Time tick 69 | for i in TIME_AXIS_MARKS: 70 | pos = timeToXCoordinate(i) 71 | print >>outFile,"\\draw[semithick] (",pos,",0.1) -- +(0,-0.2) node[anchor=north] {\small "+str(i)+"};" 72 | # -> Cactus plot 73 | for i,filename in enumerate(performances): 74 | allTimes = performances[filename] 75 | style = PAINTSTYLES[i] 76 | allTimes.sort() 77 | print >>outFile,"\\draw["+style+"] (0,0)", 78 | nofFilesSoFar = 0 79 | for t in allTimes: 80 | nofFilesSoFar += 1 81 | xPos = timeToXCoordinate(t) 82 | yPos = (HEIGHT/float(totalNofFiles))*nofFilesSoFar 83 | print >>outFile,"-| (",xPos,",",yPos,")", 84 | print >>outFile,";" 85 | print >>outFile,"\\end{tikzpicture}\n\n" 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | print >>outFile,"\\end{document}" 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /src/minisat2/Options.cc: -------------------------------------------------------------------------------- 1 | /**************************************************************************************[Options.cc] 2 | Copyright (c) 2008-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #include "Sort.h" 21 | #include "Options.h" 22 | #include "ParseUtils.h" 23 | 24 | using namespace Minisat; 25 | 26 | void Minisat::parseOptions(int& argc, char** argv, bool strict) 27 | { 28 | int i, j; 29 | for (i = j = 1; i < argc; i++){ 30 | const char* str = argv[i]; 31 | if (match(str, "--") && match(str, Option::getHelpPrefixString()) && match(str, "help")){ 32 | if (*str == '\0') 33 | printUsageAndExit(argc, argv); 34 | else if (match(str, "-verb")) 35 | printUsageAndExit(argc, argv, true); 36 | } else { 37 | bool parsed_ok = false; 38 | 39 | for (int k = 0; !parsed_ok && k < Option::getOptionList().size(); k++){ 40 | parsed_ok = Option::getOptionList()[k]->parse(argv[i]); 41 | 42 | // fprintf(stderr, "checking %d: %s against flag <%s> (%s)\n", i, argv[i], Option::getOptionList()[k]->name, parsed_ok ? "ok" : "skip"); 43 | } 44 | 45 | if (!parsed_ok){ 46 | if (strict && match(argv[i], "-")) 47 | fprintf(stderr, "ERROR! Unknown flag \"%s\". Use '--%shelp' for help.\n", argv[i], Option::getHelpPrefixString()), exit(1); 48 | else 49 | argv[j++] = argv[i]; 50 | } 51 | } 52 | } 53 | 54 | argc -= (i - j); 55 | } 56 | 57 | 58 | void Minisat::setUsageHelp (const char* str){ Option::getUsageString() = str; } 59 | void Minisat::setHelpPrefixStr (const char* str){ Option::getHelpPrefixString() = str; } 60 | void Minisat::printUsageAndExit (int /*argc*/, char** argv, bool verbose) 61 | { 62 | const char* usage = Option::getUsageString(); 63 | if (usage != NULL) 64 | fprintf(stderr, usage, argv[0]); 65 | 66 | sort(Option::getOptionList(), Option::OptionLt()); 67 | 68 | const char* prev_cat = NULL; 69 | const char* prev_type = NULL; 70 | 71 | for (int i = 0; i < Option::getOptionList().size(); i++){ 72 | const char* cat = Option::getOptionList()[i]->category; 73 | const char* type = Option::getOptionList()[i]->type_name; 74 | 75 | if (cat != prev_cat) 76 | fprintf(stderr, "\n%s OPTIONS:\n\n", cat); 77 | else if (type != prev_type) 78 | fprintf(stderr, "\n"); 79 | 80 | Option::getOptionList()[i]->help(verbose); 81 | 82 | prev_cat = Option::getOptionList()[i]->category; 83 | prev_type = Option::getOptionList()[i]->type_name; 84 | } 85 | 86 | fprintf(stderr, "\nHELP OPTIONS:\n\n"); 87 | fprintf(stderr, " --%shelp Print help message.\n", Option::getHelpPrefixString()); 88 | fprintf(stderr, " --%shelp-verb Print verbose help message.\n", Option::getHelpPrefixString()); 89 | fprintf(stderr, "\n"); 90 | exit(0); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/verifierContext.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __VERIFIER_CONTEXT__ 2 | #define __VERIFIER_CONTEXT__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "lpSolvers.hpp" 9 | #include "supersetdatabase.hpp" 10 | 11 | 12 | typedef enum { LINEAR, RELU, INPUT, MAXPOOL } NodeType; 13 | typedef enum { LEQ } ComparisonType; 14 | 15 | 16 | class VerificationProblem { 17 | private: 18 | 19 | // Network 20 | std::map nodeNumberLookup; 21 | std::vector nodeNames; 22 | std::vector nodeTypes; 23 | std::vector > > nodeConnectionIn; 24 | std::vector nodeBias; 25 | std::vector nodeNofPhases; 26 | unsigned int nofNodesWithPhases; 27 | 28 | // Constraints 29 | std::vector > > > constraints; 30 | 31 | // Initial estimates on the neural values 32 | std::vector > initialNeuronLimitBounds; 33 | 34 | // Fixed optimization function for network solving 35 | LPREALTYPE *nullOptimizationFunctionForLPSolving; 36 | 37 | // Data to make the current states of SAT and LP solver during the integrated search process 38 | // persistent 39 | SupersetDatabase cachedOptima; 40 | std::vector lastPartialVariableValuationGivenToCheckPartialNodeFixtureInLPRelaxation; 41 | 42 | // Fixed-throughout-the-solver-run information about the connection of the SAT instance to the NN-verification-problem 43 | std::vector startingSATVarsPhases; 44 | unsigned int nofSATVars; 45 | std::vector > satVarToNodeAndPhaseMapper; 46 | 47 | // Main LP Problem for checking a partial fixture -- while an assignment is gradually built, it is simply updated 48 | LPProblem lpPartialFixture; 49 | std::set literalsAlreadyFixed; // the "lpPartialFixture" needs to be rebuilt if this is empty 50 | 51 | 52 | protected: 53 | void addConstraintsToLPInstance(LPProblem &lp, unsigned int nofLPVars); 54 | void addNodePropagationInequationsToLPInstance(LPProblem &lp, unsigned int nofLPVars); 55 | void imposeNeuronValueBoundsInLPInstance(LPProblem &lp); 56 | void addReLUFixture(LPProblem &lp, unsigned int nodeNumber, unsigned int phase, unsigned int nofLPVars); 57 | void addReLUFixtureWithSlackVar(LPProblem &lp, unsigned int nodeNumber, unsigned int phase, int slackVar, unsigned int nofLPVars); 58 | void addMaxPoolFixture(LPProblem &lp,unsigned int nofNumber,const std::set knownPhaseComponents, unsigned int nofLPVars); 59 | void addMaxPoolFixtureWithSlackVar(LPProblem &lp,unsigned int nofNumber,const std::set knownPhaseComponents, int slackVar, unsigned int nofLPVars); 60 | 61 | 62 | public: 63 | 64 | // Call-back function for the solver to check a partial phase valuation for "sanity". 65 | bool checkPartialNodeFixtureInLPRelaxation(std::vector partialValuation, int nofLevel0VarsInPartialValuation, std::list > &addedClauses); 66 | 67 | // Call-back function for the solver to check data 68 | bool checkPartialNodeFixtureInSimplePropagation(std::vector currentAssignment, std::list > &addedClauses); 69 | 70 | // Call-back function for backtracking. 71 | void backtrack() { literalsAlreadyFixed.clear(); } 72 | 73 | VerificationProblem() : nullOptimizationFunctionForLPSolving(0), cachedOptima(1) {} 74 | ~VerificationProblem() { 75 | if (nullOptimizationFunctionForLPSolving!=0) delete[] nullOptimizationFunctionForLPSolving; 76 | } 77 | 78 | void load(std::string inFile); 79 | bool computeInitialNeuronLimitBounds(); 80 | bool solveLPRelavation(std::vector const &nodesToApproximate, std::vector nodePhases, std::list > &newFixationsThatAreAdmissibleInTheRelaxation, std::list > &newFixationsThatAreNotAdmissibleInTheRelaxation); 81 | void verify(); 82 | void printSMTLibInstance(bool includingApproximationConstraints); 83 | void printILPInstance(bool includingApproximationConstraints); 84 | inline unsigned int getNofSATVars() { return nofSATVars; } 85 | 86 | }; 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/minisat2/IntMap.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************************[IntMap.h] 2 | Copyright (c) 2011, Niklas Sorensson 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 4 | associated documentation files (the "Software"), to deal in the Software without restriction, 5 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 6 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or 10 | substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 13 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 15 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 16 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | **************************************************************************************************/ 18 | 19 | #ifndef Minisat_IntMap_h 20 | #define Minisat_IntMap_h 21 | 22 | #include "Vec.h" 23 | 24 | namespace Minisat { 25 | 26 | template struct MkIndexDefault { 27 | typename vec::Size operator()(T t) const { return (typename vec::Size)t; } 28 | }; 29 | 30 | template > 31 | class IntMap { 32 | vec map; 33 | MkIndex index; 34 | public: 35 | explicit IntMap(MkIndex _index = MkIndex()) : index(_index){} 36 | 37 | bool has (K k) const { return index(k) < map.size(); } 38 | 39 | const V& operator[](K k) const { assert(has(k)); return map[index(k)]; } 40 | V& operator[](K k) { assert(has(k)); return map[index(k)]; } 41 | 42 | const V* begin () const { return &map[0]; } 43 | const V* end () const { return &map[map.size()]; } 44 | V* begin () { return &map[0]; } 45 | V* end () { return &map[map.size()]; } 46 | 47 | void reserve(K key, V pad) { map.growTo(index(key)+1, pad); } 48 | void reserve(K key) { map.growTo(index(key)+1); } 49 | void insert (K key, V val, V pad){ reserve(key, pad); operator[](key) = val; } 50 | void insert (K key, V val) { reserve(key); operator[](key) = val; } 51 | 52 | void clear (bool dispose = false) { map.clear(dispose); } 53 | void moveTo (IntMap& to) { map.moveTo(to.map); to.index = index; } 54 | void copyTo (IntMap& to) const { map.copyTo(to.map); to.index = index; } 55 | }; 56 | 57 | 58 | template > 59 | class IntSet 60 | { 61 | IntMap in_set; 62 | vec xs; 63 | 64 | public: 65 | // Size operations: 66 | int size (void) const { return xs.size(); } 67 | void clear (bool free = false){ 68 | if (free) 69 | in_set.clear(true); 70 | else 71 | for (int i = 0; i < xs.size(); i++) 72 | in_set[xs[i]] = 0; 73 | xs.clear(free); 74 | } 75 | 76 | // Allow inspecting the internal vector: 77 | const vec& 78 | toVec () const { return xs; } 79 | 80 | // Vector interface: 81 | K operator [] (int index) const { return xs[index]; } 82 | 83 | 84 | void insert (K k) { in_set.reserve(k, 0); if (!in_set[k]) { in_set[k] = 1; xs.push(k); } } 85 | bool has (K k) { in_set.reserve(k, 0); return in_set[k]; } 86 | }; 87 | 88 | #if 0 89 | template > 90 | class IntMapNil { 91 | vec map; 92 | V nil; 93 | 94 | public: 95 | IntMap(){} 96 | 97 | void reserve(K); 98 | V& find (K); 99 | const V& operator[](K k) const; 100 | 101 | }; 102 | #endif 103 | 104 | //================================================================================================= 105 | } // namespace Minisat 106 | #endif 107 | -------------------------------------------------------------------------------- /src/minisat2/ParseUtils.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************[ParseUtils.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_ParseUtils_h 22 | #define Minisat_ParseUtils_h 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include "XAlloc.h" 30 | 31 | namespace Minisat { 32 | 33 | //------------------------------------------------------------------------------------------------- 34 | // A simple buffered character stream class: 35 | 36 | 37 | 38 | class StreamBuffer { 39 | gzFile in; 40 | unsigned char* buf; 41 | int pos; 42 | int size; 43 | 44 | enum { buffer_size = 64*1024 }; 45 | 46 | void assureLookahead() { 47 | if (pos >= size) { 48 | pos = 0; 49 | size = gzread(in, buf, buffer_size); } } 50 | 51 | public: 52 | explicit StreamBuffer(gzFile i) : in(i), pos(0), size(0){ 53 | buf = (unsigned char*)xrealloc(NULL, buffer_size); 54 | assureLookahead(); 55 | } 56 | ~StreamBuffer() { free(buf); } 57 | 58 | int operator * () const { return (pos >= size) ? EOF : buf[pos]; } 59 | void operator ++ () { pos++; assureLookahead(); } 60 | int position () const { return pos; } 61 | }; 62 | 63 | 64 | //------------------------------------------------------------------------------------------------- 65 | // End-of-file detection functions for StreamBuffer and char*: 66 | 67 | 68 | static inline bool isEof(StreamBuffer& in) { return *in == EOF; } 69 | static inline bool isEof(const char* in) { return *in == '\0'; } 70 | 71 | //------------------------------------------------------------------------------------------------- 72 | // Generic parse functions parametrized over the input-stream type. 73 | 74 | 75 | template 76 | static void skipWhitespace(B& in) { 77 | while ((*in >= 9 && *in <= 13) || *in == 32) 78 | ++in; } 79 | 80 | 81 | template 82 | static void skipLine(B& in) { 83 | for (;;){ 84 | if (isEof(in)) return; 85 | if (*in == '\n') { ++in; return; } 86 | ++in; } } 87 | 88 | 89 | template 90 | static int parseInt(B& in) { 91 | int val = 0; 92 | bool neg = false; 93 | skipWhitespace(in); 94 | if (*in == '-') neg = true, ++in; 95 | else if (*in == '+') ++in; 96 | if (*in < '0' || *in > '9') fprintf(stderr, "PARSE ERROR! Unexpected char: %c\n", *in), exit(3); 97 | while (*in >= '0' && *in <= '9') 98 | val = val*10 + (*in - '0'), 99 | ++in; 100 | return neg ? -val : val; } 101 | 102 | 103 | // String matching: in case of a match the input iterator will be advanced the corresponding 104 | // number of characters. 105 | template 106 | static bool match(B& in, const char* str) { 107 | int i; 108 | for (i = 0; str[i] != '\0'; i++) 109 | if (in[i] != str[i]) 110 | return false; 111 | 112 | in += i; 113 | 114 | return true; 115 | } 116 | 117 | // String matching: consumes characters eagerly, but does not require random access iterator. 118 | template 119 | static bool eagerMatch(B& in, const char* str) { 120 | for (; *str != '\0'; ++str, ++in) 121 | if (*str != *in) 122 | return false; 123 | return true; } 124 | 125 | 126 | //================================================================================================= 127 | } 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # 3 | # Testing pyBrain 4 | # 5 | import os, pygame, pygame.locals, sys, random, math 6 | 7 | # CONSTANTS 8 | XSIZE = 480 9 | YSIZE = 480 10 | 11 | # OBSTACLE/ROBOT RADIUS 12 | OBSTACLE_INNER_RADIUS = 10 13 | ROBOT_INNER_RADIUS = 10 14 | JOINT_OUTER_RADIUS = 30 15 | 16 | 17 | # Prepare screen 18 | screen = pygame.display.set_mode((XSIZE,YSIZE)) 19 | pygame.display.set_caption('Collision Yes/No Visualizer') 20 | clock = pygame.time.Clock() 21 | isPaused = False 22 | screenBuffer = pygame.Surface(screen.get_size()) 23 | screenBuffer = screenBuffer.convert() 24 | 25 | # Buffer for results 26 | COLLISION_CASES = [] 27 | NON_COLLISION_CASES = [] 28 | 29 | # distance computation 30 | def computeDistance(a,b): 31 | diffA = a[0]-b[0] 32 | diffB = a[1]-b[1] 33 | return math.sqrt(diffA*diffA+diffB*diffB) 34 | 35 | 36 | outFile = open("collisions.csv","a") 37 | 38 | # Main loop 39 | nofExamplesWritten = 0 40 | while 1: 41 | 42 | currentPos = (XSIZE/2,YSIZE*5/6) 43 | currentSpeed = 0.2 44 | currentDirection = math.pi 45 | directionChange = random.random()*0.0012-0.0006 46 | 47 | obstaclePos = (random.random()*XSIZE,random.random()*YSIZE) 48 | obstacleSpeed = 0.1+random.random()*0.2 49 | obstacleDirection = (0.4+0.2*random.random())*math.pi 50 | obstacleDirectionChange = random.random()*0.0012-0.0006 51 | 52 | 53 | case = (obstaclePos[0]/XSIZE,obstaclePos[1]/YSIZE,obstacleSpeed,obstacleDirection/math.pi,obstacleDirectionChange/0.0020,directionChange/0.0020) 54 | 55 | 56 | collision = 0 # 1: Maybe, 2: Sure 57 | 58 | screenBuffer.fill((64, 64, 64)) 59 | for i in range(0,3000): 60 | if (i % 10) == 0: 61 | if pygame.display.get_active(): 62 | if collision==0: 63 | collisionColor=0 64 | elif collision==1: 65 | collisionColor=128 66 | elif collision==2: 67 | collisionColor=255 68 | pygame.draw.circle(screenBuffer,(255,255,collisionColor),(int(currentPos[0]),int(currentPos[1])),ROBOT_INNER_RADIUS) 69 | pygame.draw.circle(screenBuffer,(255,collisionColor,255),(int(obstaclePos[0]),int(obstaclePos[1])),OBSTACLE_INNER_RADIUS) 70 | currentPos = (math.sin(currentDirection)*currentSpeed+currentPos[0],math.cos(currentDirection)*currentSpeed+currentPos[1]) 71 | currentDirection += directionChange 72 | obstaclePos = (math.sin(obstacleDirection)*obstacleSpeed+obstaclePos[0],math.cos(obstacleDirection)*obstacleSpeed+obstaclePos[1]) 73 | obstacleDirection += obstacleDirectionChange 74 | 75 | # Distance 76 | distance = computeDistance(currentPos,obstaclePos) 77 | if distance100: 98 | NON_COLLISION_CASES = NON_COLLISION_CASES[0:100] 99 | if len(COLLISION_CASES)>100: 100 | COLLISION_CASES = COLLISION_CASES[0:100] 101 | 102 | # We have both collision and non-collision cases? Then flush them out! 103 | if len(NON_COLLISION_CASES)>0 and len(COLLISION_CASES)>0: 104 | outFile.write(",".join([str(a) for a in COLLISION_CASES[0]])+",1\n") 105 | outFile.write(",".join([str(a) for a in NON_COLLISION_CASES[0]])+",0\n") 106 | outFile.flush() 107 | nofExamplesWritten += 2 108 | NON_COLLISION_CASES = NON_COLLISION_CASES[1:] 109 | COLLISION_CASES = COLLISION_CASES[1:] 110 | 111 | if (nofExamplesWritten % 100)==0: 112 | sys.stdout.write(str(nofExamplesWritten)+"...") 113 | sys.stdout.flush() 114 | 115 | 116 | # Event loop 117 | for event in pygame.event.get(): 118 | 119 | if event.type == pygame.locals.QUIT or (event.type == pygame.locals.KEYDOWN and event.key == pygame.locals.K_ESCAPE): 120 | # from pybrain.tools.xml.networkwriter import NetworkWriter 121 | # NetworkWriter.writeToFile(net, 'finalNet.xml') 122 | sys.exit(0) 123 | if (event.type == pygame.locals.KEYDOWN and event.key == pygame.locals.K_SPACE): 124 | isPaused = not isPaused 125 | 126 | 127 | -------------------------------------------------------------------------------- /src/minisat2/Alloc.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************************[Alloc.h] 2 | Copyright (c) 2008-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | 21 | #ifndef Minisat_Alloc_h 22 | #define Minisat_Alloc_h 23 | 24 | #include "XAlloc.h" 25 | #include "Vec.h" 26 | 27 | namespace Minisat { 28 | 29 | //================================================================================================= 30 | // Simple Region-based memory allocator: 31 | 32 | template 33 | class RegionAllocator 34 | { 35 | T* memory; 36 | uint32_t sz; 37 | uint32_t cap; 38 | uint32_t wasted_; 39 | 40 | void capacity(uint32_t min_cap); 41 | 42 | public: 43 | // TODO: make this a class for better type-checking? 44 | typedef uint32_t Ref; 45 | enum { Ref_Undef = UINT32_MAX }; 46 | enum { Unit_Size = sizeof(T) }; 47 | 48 | explicit RegionAllocator(uint32_t start_cap = 1024*1024) : memory(NULL), sz(0), cap(0), wasted_(0){ capacity(start_cap); } 49 | ~RegionAllocator() 50 | { 51 | if (memory != NULL) 52 | ::free(memory); 53 | } 54 | 55 | 56 | uint32_t size () const { return sz; } 57 | uint32_t wasted () const { return wasted_; } 58 | 59 | Ref alloc (int size); 60 | void free (int size) { wasted_ += size; } 61 | 62 | // Deref, Load Effective Address (LEA), Inverse of LEA (AEL): 63 | T& operator[](Ref r) { assert(r < sz); return memory[r]; } 64 | const T& operator[](Ref r) const { assert(r < sz); return memory[r]; } 65 | 66 | T* lea (Ref r) { assert(r < sz); return &memory[r]; } 67 | const T* lea (Ref r) const { assert(r < sz); return &memory[r]; } 68 | Ref ael (const T* t) { assert((void*)t >= (void*)&memory[0] && (void*)t < (void*)&memory[sz-1]); 69 | return (Ref)(t - &memory[0]); } 70 | 71 | void moveTo(RegionAllocator& to) { 72 | if (to.memory != NULL) ::free(to.memory); 73 | to.memory = memory; 74 | to.sz = sz; 75 | to.cap = cap; 76 | to.wasted_ = wasted_; 77 | 78 | memory = NULL; 79 | sz = cap = wasted_ = 0; 80 | } 81 | 82 | 83 | }; 84 | 85 | template 86 | void RegionAllocator::capacity(uint32_t min_cap) 87 | { 88 | if (cap >= min_cap) return; 89 | 90 | uint32_t prev_cap = cap; 91 | while (cap < min_cap){ 92 | // NOTE: Multiply by a factor (13/8) without causing overflow, then add 2 and make the 93 | // result even by clearing the least significant bit. The resulting sequence of capacities 94 | // is carefully chosen to hit a maximum capacity that is close to the '2^32-1' limit when 95 | // using 'uint32_t' as indices so that as much as possible of this space can be used. 96 | uint32_t delta = ((cap >> 1) + (cap >> 3) + 2) & ~1; 97 | cap += delta; 98 | 99 | if (cap <= prev_cap) 100 | throw OutOfMemoryException(); 101 | } 102 | // printf(" .. (%p) cap = %u\n", this, cap); 103 | 104 | assert(cap > 0); 105 | memory = (T*)xrealloc(memory, sizeof(T)*cap); 106 | } 107 | 108 | 109 | template 110 | typename RegionAllocator::Ref 111 | RegionAllocator::alloc(int size) 112 | { 113 | // printf("ALLOC called (this = %p, size = %d)\n", this, size); fflush(stdout); 114 | assert(size > 0); 115 | capacity(sz + size); 116 | 117 | uint32_t prev_sz = sz; 118 | sz += size; 119 | 120 | // Handle overflow: 121 | if (sz < prev_sz) 122 | throw OutOfMemoryException(); 123 | 124 | return prev_sz; 125 | } 126 | 127 | 128 | //================================================================================================= 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /src/minisat2/System.cc: -------------------------------------------------------------------------------- 1 | /***************************************************************************************[System.cc] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #include 22 | #include 23 | 24 | #include "System.h" 25 | 26 | #if defined(__linux__) 27 | 28 | #include 29 | 30 | using namespace Minisat; 31 | 32 | static inline int memReadStat(int field) 33 | { 34 | char name[256]; 35 | pid_t pid = getpid(); 36 | int value; 37 | 38 | sprintf(name, "/proc/%d/statm", pid); 39 | FILE* in = fopen(name, "rb"); 40 | if (in == NULL) return 0; 41 | 42 | for (; field >= 0; field--) 43 | if (fscanf(in, "%d", &value) != 1) 44 | printf("ERROR! Failed to parse memory statistics from \"/proc\".\n"), exit(1); 45 | fclose(in); 46 | return value; 47 | } 48 | 49 | 50 | static inline int memReadPeak(void) 51 | { 52 | char name[256]; 53 | pid_t pid = getpid(); 54 | 55 | sprintf(name, "/proc/%d/status", pid); 56 | FILE* in = fopen(name, "rb"); 57 | if (in == NULL) return 0; 58 | 59 | // Find the correct line, beginning with "VmPeak:": 60 | int peak_kb = 0; 61 | while (!feof(in) && fscanf(in, "VmPeak: %d kB", &peak_kb) != 1) 62 | while (!feof(in) && fgetc(in) != '\n') 63 | ; 64 | fclose(in); 65 | 66 | return peak_kb; 67 | } 68 | 69 | double Minisat::memUsed() { return (double)memReadStat(0) * (double)getpagesize() / (1024*1024); } 70 | double Minisat::memUsedPeak(bool strictlyPeak) { 71 | double peak = memReadPeak() / (double)1024; 72 | return peak == 0 && !strictlyPeak ? memUsed() : peak; } 73 | 74 | #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__gnu_hurd__) 75 | 76 | double Minisat::memUsed() { 77 | struct rusage ru; 78 | getrusage(RUSAGE_SELF, &ru); 79 | return (double)ru.ru_maxrss / 1024; } 80 | double Minisat::memUsedPeak() { return memUsed(); } 81 | 82 | 83 | #elif defined(__APPLE__) 84 | #include 85 | 86 | double Minisat::memUsed() { 87 | malloc_statistics_t t; 88 | malloc_zone_statistics(NULL, &t); 89 | return (double)t.max_size_in_use / (1024*1024); } 90 | double Minisat::memUsedPeak() { return memUsed(); } 91 | 92 | #else 93 | double Minisat::memUsed() { return 0; } 94 | double Minisat::memUsedPeak() { return 0; } 95 | #endif 96 | 97 | 98 | void Minisat::setX86FPUPrecision() 99 | { 100 | #if defined(__linux__) && defined(_FPU_EXTENDED) && defined(_FPU_DOUBLE) && defined(_FPU_GETCW) 101 | // Only correct FPU precision on Linux architectures that needs and supports it: 102 | fpu_control_t oldcw, newcw; 103 | _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 104 | printf("WARNING: for repeatability, setting FPU to use double precision\n"); 105 | #endif 106 | } 107 | 108 | 109 | #if !defined(_MSC_VER) && !defined(__MINGW32__) 110 | void Minisat::limitMemory(uint64_t max_mem_mb) 111 | { 112 | // FIXME: OpenBSD does not support RLIMIT_AS. Not sure how well RLIMIT_DATA works instead. 113 | #if defined(__OpenBSD__) 114 | #define RLIMIT_AS RLIMIT_DATA 115 | #endif 116 | 117 | // Set limit on virtual memory: 118 | if (max_mem_mb != 0){ 119 | rlim_t new_mem_lim = (rlim_t)max_mem_mb * 1024*1024; 120 | rlimit rl; 121 | getrlimit(RLIMIT_AS, &rl); 122 | if (rl.rlim_max == RLIM_INFINITY || new_mem_lim < rl.rlim_max){ 123 | rl.rlim_cur = new_mem_lim; 124 | if (setrlimit(RLIMIT_AS, &rl) == -1) 125 | printf("WARNING! Could not set resource limit: Virtual memory.\n"); 126 | } 127 | } 128 | 129 | #if defined(__OpenBSD__) 130 | #undef RLIMIT_AS 131 | #endif 132 | } 133 | #else 134 | void Minisat::limitMemory(uint64_t /*max_mem_mb*/) 135 | { 136 | printf("WARNING! Memory limit not supported on this architecture.\n"); 137 | } 138 | #endif 139 | 140 | 141 | #if !defined(_MSC_VER) && !defined(__MINGW32__) 142 | void Minisat::limitTime(uint32_t max_cpu_time) 143 | { 144 | if (max_cpu_time != 0){ 145 | rlimit rl; 146 | getrlimit(RLIMIT_CPU, &rl); 147 | if (rl.rlim_max == RLIM_INFINITY || (rlim_t)max_cpu_time < rl.rlim_max){ 148 | rl.rlim_cur = max_cpu_time; 149 | if (setrlimit(RLIMIT_CPU, &rl) == -1) 150 | printf("WARNING! Could not set resource limit: CPU-time.\n"); 151 | } 152 | } 153 | } 154 | #else 155 | void Minisat::limitTime(uint32_t /*max_cpu_time*/) 156 | { 157 | printf("WARNING! CPU-time limit not supported on this architecture.\n"); 158 | } 159 | #endif 160 | 161 | 162 | void Minisat::sigTerm(void handler(int)) 163 | { 164 | signal(SIGINT, handler); 165 | signal(SIGTERM,handler); 166 | #ifdef SIGXCPU 167 | signal(SIGXCPU,handler); 168 | #endif 169 | } 170 | -------------------------------------------------------------------------------- /src/minisat2/Heap.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************[Heap.h] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_Heap_h 22 | #define Minisat_Heap_h 23 | 24 | #include "Vec.h" 25 | #include "IntMap.h" 26 | 27 | namespace Minisat { 28 | 29 | //================================================================================================= 30 | // A heap implementation with support for decrease/increase key. 31 | 32 | 33 | template > 34 | class Heap { 35 | vec heap; // Heap of Keys 36 | IntMap indices; // Each Key's position (index) in the Heap 37 | Comp lt; // The heap is a minimum-heap with respect to this comparator 38 | 39 | // Index "traversal" functions 40 | static inline int left (int i) { return i*2+1; } 41 | static inline int right (int i) { return (i+1)*2; } 42 | static inline int parent(int i) { return (i-1) >> 1; } 43 | 44 | 45 | void percolateUp(int i) 46 | { 47 | K x = heap[i]; 48 | int p = parent(i); 49 | 50 | while (i != 0 && lt(x, heap[p])){ 51 | heap[i] = heap[p]; 52 | indices[heap[p]] = i; 53 | i = p; 54 | p = parent(p); 55 | } 56 | heap [i] = x; 57 | indices[x] = i; 58 | } 59 | 60 | 61 | void percolateDown(int i) 62 | { 63 | K x = heap[i]; 64 | while (left(i) < heap.size()){ 65 | int child = right(i) < heap.size() && lt(heap[right(i)], heap[left(i)]) ? right(i) : left(i); 66 | if (!lt(heap[child], x)) break; 67 | heap[i] = heap[child]; 68 | indices[heap[i]] = i; 69 | i = child; 70 | } 71 | heap [i] = x; 72 | indices[x] = i; 73 | } 74 | 75 | 76 | public: 77 | Heap(const Comp& c, MkIndex _index = MkIndex()) : indices(_index), lt(c) {} 78 | 79 | int size () const { return heap.size(); } 80 | bool empty () const { return heap.size() == 0; } 81 | bool inHeap (K k) const { return indices.has(k) && indices[k] >= 0; } 82 | int operator[](int index) const { assert(index < heap.size()); return heap[index]; } 83 | 84 | void decrease (K k) { assert(inHeap(k)); percolateUp (indices[k]); } 85 | void increase (K k) { assert(inHeap(k)); percolateDown(indices[k]); } 86 | 87 | 88 | // Safe variant of insert/decrease/increase: 89 | void update(K k) 90 | { 91 | if (!inHeap(k)) 92 | insert(k); 93 | else { 94 | percolateUp(indices[k]); 95 | percolateDown(indices[k]); } 96 | } 97 | 98 | 99 | void insert(K k) 100 | { 101 | indices.reserve(k, -1); 102 | assert(!inHeap(k)); 103 | 104 | indices[k] = heap.size(); 105 | heap.push(k); 106 | percolateUp(indices[k]); 107 | } 108 | 109 | 110 | void remove(K k) 111 | { 112 | assert(inHeap(k)); 113 | 114 | int k_pos = indices[k]; 115 | indices[k] = -1; 116 | 117 | if (k_pos < heap.size()-1){ 118 | heap[k_pos] = heap.last(); 119 | indices[heap[k_pos]] = k_pos; 120 | heap.pop(); 121 | percolateDown(k_pos); 122 | }else 123 | heap.pop(); 124 | } 125 | 126 | 127 | K removeMin() 128 | { 129 | K x = heap[0]; 130 | heap[0] = heap.last(); 131 | indices[heap[0]] = 0; 132 | indices[x] = -1; 133 | heap.pop(); 134 | if (heap.size() > 1) percolateDown(0); 135 | return x; 136 | } 137 | 138 | 139 | // Rebuild the heap from scratch, using the elements in 'ns': 140 | void build(const vec& ns) { 141 | for (int i = 0; i < heap.size(); i++) 142 | indices[heap[i]] = -1; 143 | heap.clear(); 144 | 145 | for (int i = 0; i < ns.size(); i++){ 146 | // TODO: this should probably call reserve instead of relying on it being reserved already. 147 | assert(indices.has(ns[i])); 148 | indices[ns[i]] = i; 149 | heap.push(ns[i]); } 150 | 151 | for (int i = heap.size() / 2 - 1; i >= 0; i--) 152 | percolateDown(i); 153 | } 154 | 155 | void clear(bool dispose = false) 156 | { 157 | // TODO: shouldn't the 'indices' map also be dispose-cleared? 158 | for (int i = 0; i < heap.size(); i++) 159 | indices[heap[i]] = -1; 160 | heap.clear(dispose); 161 | } 162 | }; 163 | 164 | 165 | //================================================================================================= 166 | } 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /src/minisat2/Vec.h: -------------------------------------------------------------------------------- 1 | /*******************************************************************************************[Vec.h] 2 | Copyright (c) 2003-2007, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #ifndef Minisat_Vec_h 22 | #define Minisat_Vec_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "IntTypes.h" 29 | #include "XAlloc.h" 30 | 31 | namespace Minisat { 32 | 33 | //================================================================================================= 34 | // Automatically resizable arrays 35 | // 36 | // NOTE! Don't use this vector on datatypes that cannot be re-located in memory (with realloc) 37 | 38 | template 39 | class vec { 40 | public: 41 | typedef _Size Size; 42 | private: 43 | T* data; 44 | Size sz; 45 | Size cap; 46 | 47 | // Don't allow copying (error prone): 48 | vec& operator=(vec& other); 49 | vec (vec& other); 50 | 51 | static inline Size max(Size x, Size y){ return (x > y) ? x : y; } 52 | 53 | public: 54 | // Constructors: 55 | vec() : data(NULL), sz(0), cap(0) { } 56 | explicit vec(Size size) : data(NULL), sz(0), cap(0) { growTo(size); } 57 | vec(Size size, const T& pad) : data(NULL), sz(0), cap(0) { growTo(size, pad); } 58 | ~vec() { clear(true); } 59 | 60 | // Pointer to first element: 61 | operator T* (void) { return data; } 62 | 63 | // Size operations: 64 | Size size (void) const { return sz; } 65 | void shrink (Size nelems) { assert(nelems <= sz); for (Size i = 0; i < nelems; i++) sz--, data[sz].~T(); } 66 | void shrink_ (Size nelems) { assert(nelems <= sz); sz -= nelems; } 67 | int capacity (void) const { return cap; } 68 | void capacity (Size min_cap); 69 | void growTo (Size size); 70 | void growTo (Size size, const T& pad); 71 | void clear (bool dealloc = false); 72 | 73 | // Stack interface: 74 | void push (void) { if (sz == cap) capacity(sz+1); new (&data[sz]) T(); sz++; } 75 | //void push (const T& elem) { if (sz == cap) capacity(sz+1); data[sz++] = elem; } 76 | void push (const T& elem) { if (sz == cap) capacity(sz+1); new (&data[sz++]) T(elem); } 77 | void push_ (const T& elem) { assert(sz < cap); data[sz++] = elem; } 78 | void pop (void) { assert(sz > 0); sz--, data[sz].~T(); } 79 | // NOTE: it seems possible that overflow can happen in the 'sz+1' expression of 'push()', but 80 | // in fact it can not since it requires that 'cap' is equal to INT_MAX. This in turn can not 81 | // happen given the way capacities are calculated (below). Essentially, all capacities are 82 | // even, but INT_MAX is odd. 83 | 84 | const T& last (void) const { return data[sz-1]; } 85 | T& last (void) { return data[sz-1]; } 86 | 87 | // Vector interface: 88 | const T& operator [] (Size index) const { return data[index]; } 89 | T& operator [] (Size index) { return data[index]; } 90 | 91 | // Duplicatation (preferred instead): 92 | void copyTo(vec& copy) const { copy.clear(); copy.growTo(sz); for (Size i = 0; i < sz; i++) copy[i] = data[i]; } 93 | void moveTo(vec& dest) { dest.clear(true); dest.data = data; dest.sz = sz; dest.cap = cap; data = NULL; sz = 0; cap = 0; } 94 | }; 95 | 96 | 97 | template 98 | void vec::capacity(Size min_cap) { 99 | if (cap >= min_cap) return; 100 | Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 101 | const Size size_max = std::numeric_limits::max(); 102 | if ( ((size_max <= std::numeric_limits::max()) && (add > size_max - cap)) 103 | || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM) ) 104 | throw OutOfMemoryException(); 105 | } 106 | 107 | 108 | template 109 | void vec::growTo(Size size, const T& pad) { 110 | if (sz >= size) return; 111 | capacity(size); 112 | for (Size i = sz; i < size; i++) data[i] = pad; 113 | sz = size; } 114 | 115 | 116 | template 117 | void vec::growTo(Size size) { 118 | if (sz >= size) return; 119 | capacity(size); 120 | for (Size i = sz; i < size; i++) new (&data[i]) T(); 121 | sz = size; } 122 | 123 | 124 | template 125 | void vec::clear(bool dealloc) { 126 | if (data != NULL){ 127 | for (Size i = 0; i < sz; i++) data[i].~T(); 128 | sz = 0; 129 | if (dealloc) free(data), data = NULL, cap = 0; } } 130 | 131 | //================================================================================================= 132 | } 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /src/minisat2/Main.cc: -------------------------------------------------------------------------------- 1 | /*****************************************************************************************[Main.cc] 2 | Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson 3 | Copyright (c) 2007-2010, Niklas Sorensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 6 | associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or 12 | substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 15 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 18 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | **************************************************************************************************/ 20 | 21 | #include 22 | #include 23 | 24 | #include "System.h" 25 | #include "ParseUtils.h" 26 | #include "Options.h" 27 | #include "Dimacs.h" 28 | #include "Solver.h" 29 | 30 | using namespace Minisat; 31 | 32 | //================================================================================================= 33 | 34 | 35 | static Solver* solver; 36 | // Terminate by notifying the solver and back out gracefully. This is mainly to have a test-case 37 | // for this feature of the Solver as it may take longer than an immediate call to '_exit()'. 38 | static void SIGINT_interrupt(int) { solver->interrupt(); } 39 | 40 | // Note that '_exit()' rather than 'exit()' has to be used. The reason is that 'exit()' calls 41 | // destructors and may cause deadlocks if a malloc/free function happens to be running (these 42 | // functions are guarded by locks for multithreaded use). 43 | static void SIGINT_exit(int) { 44 | printf("\n"); printf("*** INTERRUPTED ***\n"); 45 | if (solver->verbosity > 0){ 46 | solver->printStats(); 47 | printf("\n"); printf("*** INTERRUPTED ***\n"); } 48 | _exit(1); } 49 | 50 | 51 | //================================================================================================= 52 | // Main: 53 | 54 | 55 | int main(int argc, char** argv) 56 | { 57 | try { 58 | setUsageHelp("USAGE: %s [options] \n\n where input may be either in plain or gzipped DIMACS.\n"); 59 | setX86FPUPrecision(); 60 | 61 | // Extra options: 62 | // 63 | IntOption verb ("MAIN", "verb", "Verbosity level (0=silent, 1=some, 2=more).", 1, IntRange(0, 2)); 64 | IntOption cpu_lim("MAIN", "cpu-lim","Limit on CPU time allowed in seconds.\n", 0, IntRange(0, INT32_MAX)); 65 | IntOption mem_lim("MAIN", "mem-lim","Limit on memory usage in megabytes.\n", 0, IntRange(0, INT32_MAX)); 66 | BoolOption strictp("MAIN", "strict", "Validate DIMACS header during parsing.", false); 67 | 68 | parseOptions(argc, argv, true); 69 | 70 | Solver S; 71 | double initial_time = cpuTime(); 72 | 73 | S.verbosity = verb; 74 | 75 | solver = &S; 76 | // Use signal handlers that forcibly quit until the solver will be able to respond to 77 | // interrupts: 78 | sigTerm(SIGINT_exit); 79 | 80 | // Try to set resource limits: 81 | if (cpu_lim != 0) limitTime(cpu_lim); 82 | if (mem_lim != 0) limitMemory(mem_lim); 83 | 84 | if (argc == 1) 85 | printf("Reading from standard input... Use '--help' for help.\n"); 86 | 87 | gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb"); 88 | if (in == NULL) 89 | printf("ERROR! Could not open file: %s\n", argc == 1 ? "" : argv[1]), exit(1); 90 | 91 | if (S.verbosity > 0){ 92 | printf("============================[ Problem Statistics ]=============================\n"); 93 | printf("| |\n"); } 94 | 95 | parse_DIMACS(in, S, (bool)strictp); 96 | gzclose(in); 97 | FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL; 98 | 99 | if (S.verbosity > 0){ 100 | printf("| Number of variables: %12d |\n", S.nVars()); 101 | printf("| Number of clauses: %12d |\n", S.nClauses()); } 102 | 103 | double parsed_time = cpuTime(); 104 | if (S.verbosity > 0){ 105 | printf("| Parse time: %12.2f s |\n", parsed_time - initial_time); 106 | printf("| |\n"); } 107 | 108 | // Change to signal-handlers that will only notify the solver and allow it to terminate 109 | // voluntarily: 110 | sigTerm(SIGINT_interrupt); 111 | 112 | if (!S.simplify()){ 113 | if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res); 114 | if (S.verbosity > 0){ 115 | printf("===============================================================================\n"); 116 | printf("Solved by unit propagation\n"); 117 | S.printStats(); 118 | printf("\n"); } 119 | printf("UNSATISFIABLE\n"); 120 | exit(20); 121 | } 122 | 123 | vec dummy; 124 | lbool ret = S.solveLimited(dummy); 125 | if (S.verbosity > 0){ 126 | S.printStats(); 127 | printf("\n"); } 128 | printf(ret == l_True ? "SATISFIABLE\n" : ret == l_False ? "UNSATISFIABLE\n" : "INDETERMINATE\n"); 129 | if (res != NULL){ 130 | if (ret == l_True){ 131 | fprintf(res, "SAT\n"); 132 | for (int i = 0; i < S.nVars(); i++) 133 | if (S.model[i] != l_Undef) 134 | fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1); 135 | fprintf(res, " 0\n"); 136 | }else if (ret == l_False) 137 | fprintf(res, "UNSAT\n"); 138 | else 139 | fprintf(res, "INDET\n"); 140 | fclose(res); 141 | } 142 | 143 | #ifdef NDEBUG 144 | exit(ret == l_True ? 10 : ret == l_False ? 20 : 0); // (faster than "return", which will invoke the destructor for 'Solver') 145 | #else 146 | return (ret == l_True ? 10 : ret == l_False ? 20 : 0); 147 | #endif 148 | } catch (OutOfMemoryException&){ 149 | printf("===============================================================================\n"); 150 | printf("INDETERMINATE\n"); 151 | exit(0); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/minisat2/Map.h: -------------------------------------------------------------------------------- 1 | /*******************************************************************************************[Map.h] 2 | Copyright (c) 2006-2010, Niklas Sorensson 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 5 | associated documentation files (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or 11 | substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 14 | NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 17 | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | **************************************************************************************************/ 19 | 20 | #ifndef Minisat_Map_h 21 | #define Minisat_Map_h 22 | 23 | #include "IntTypes.h" 24 | #include "Vec.h" 25 | 26 | namespace Minisat { 27 | 28 | //================================================================================================= 29 | // Default hash/equals functions 30 | // 31 | 32 | template struct Hash { uint32_t operator()(const K& k) const { return hash(k); } }; 33 | template struct Equal { bool operator()(const K& k1, const K& k2) const { return k1 == k2; } }; 34 | 35 | template struct DeepHash { uint32_t operator()(const K* k) const { return hash(*k); } }; 36 | template struct DeepEqual { bool operator()(const K* k1, const K* k2) const { return *k1 == *k2; } }; 37 | 38 | static inline uint32_t hash(uint32_t x){ return x; } 39 | static inline uint32_t hash(uint64_t x){ return (uint32_t)x; } 40 | static inline uint32_t hash(int32_t x) { return (uint32_t)x; } 41 | static inline uint32_t hash(int64_t x) { return (uint32_t)x; } 42 | 43 | 44 | //================================================================================================= 45 | // Some primes 46 | // 47 | 48 | static const int nprimes = 25; 49 | static const int primes [nprimes] = { 31, 73, 151, 313, 643, 1291, 2593, 5233, 10501, 21013, 42073, 84181, 168451, 337219, 674701, 1349473, 2699299, 5398891, 10798093, 21596719, 43193641, 86387383, 172775299, 345550609, 691101253 }; 50 | 51 | //================================================================================================= 52 | // Hash table implementation of Maps 53 | // 54 | 55 | template, class E = Equal > 56 | class Map { 57 | public: 58 | struct Pair { K key; D data; }; 59 | 60 | private: 61 | H hash; 62 | E equals; 63 | 64 | vec* table; 65 | int cap; 66 | int size; 67 | 68 | // Don't allow copying (error prone): 69 | Map& operator = (Map& other); 70 | Map (Map& other); 71 | 72 | bool checkCap(int new_size) const { return new_size > cap; } 73 | 74 | int32_t index (const K& k) const { return hash(k) % cap; } 75 | void _insert (const K& k, const D& d) { 76 | vec& ps = table[index(k)]; 77 | ps.push(); ps.last().key = k; ps.last().data = d; } 78 | 79 | void rehash () { 80 | const vec* old = table; 81 | 82 | int old_cap = cap; 83 | int newsize = primes[0]; 84 | for (int i = 1; newsize <= cap && i < nprimes; i++) 85 | newsize = primes[i]; 86 | 87 | table = new vec[newsize]; 88 | cap = newsize; 89 | 90 | for (int i = 0; i < old_cap; i++){ 91 | for (int j = 0; j < old[i].size(); j++){ 92 | _insert(old[i][j].key, old[i][j].data); }} 93 | 94 | delete [] old; 95 | 96 | // printf(" --- rehashing, old-cap=%d, new-cap=%d\n", cap, newsize); 97 | } 98 | 99 | 100 | public: 101 | 102 | Map () : table(NULL), cap(0), size(0) {} 103 | Map (const H& h, const E& e) : hash(h), equals(e), table(NULL), cap(0), size(0){} 104 | ~Map () { delete [] table; } 105 | 106 | // PRECONDITION: the key must already exist in the map. 107 | const D& operator [] (const K& k) const 108 | { 109 | assert(size != 0); 110 | const D* res = NULL; 111 | const vec& ps = table[index(k)]; 112 | for (int i = 0; i < ps.size(); i++) 113 | if (equals(ps[i].key, k)) 114 | res = &ps[i].data; 115 | assert(res != NULL); 116 | return *res; 117 | } 118 | 119 | // PRECONDITION: the key must already exist in the map. 120 | D& operator [] (const K& k) 121 | { 122 | assert(size != 0); 123 | D* res = NULL; 124 | vec& ps = table[index(k)]; 125 | for (int i = 0; i < ps.size(); i++) 126 | if (equals(ps[i].key, k)) 127 | res = &ps[i].data; 128 | assert(res != NULL); 129 | return *res; 130 | } 131 | 132 | // PRECONDITION: the key must *NOT* exist in the map. 133 | void insert (const K& k, const D& d) { if (checkCap(size+1)) rehash(); _insert(k, d); size++; } 134 | bool peek (const K& k, D& d) const { 135 | if (size == 0) return false; 136 | const vec& ps = table[index(k)]; 137 | for (int i = 0; i < ps.size(); i++) 138 | if (equals(ps[i].key, k)){ 139 | d = ps[i].data; 140 | return true; } 141 | return false; 142 | } 143 | 144 | bool has (const K& k) const { 145 | if (size == 0) return false; 146 | const vec& ps = table[index(k)]; 147 | for (int i = 0; i < ps.size(); i++) 148 | if (equals(ps[i].key, k)) 149 | return true; 150 | return false; 151 | } 152 | 153 | // PRECONDITION: the key must exist in the map. 154 | void remove(const K& k) { 155 | assert(table != NULL); 156 | vec& ps = table[index(k)]; 157 | int j = 0; 158 | for (; j < ps.size() && !equals(ps[j].key, k); j++); 159 | assert(j < ps.size()); 160 | ps[j] = ps.last(); 161 | ps.pop(); 162 | size--; 163 | } 164 | 165 | void clear () { 166 | cap = size = 0; 167 | delete [] table; 168 | table = NULL; 169 | } 170 | 171 | int elems() const { return size; } 172 | int bucket_count() const { return cap; } 173 | 174 | // NOTE: the hash and equality objects are not moved by this method: 175 | void moveTo(Map& other){ 176 | delete [] other.table; 177 | 178 | other.table = table; 179 | other.cap = cap; 180 | other.size = size; 181 | 182 | table = NULL; 183 | size = cap = 0; 184 | } 185 | 186 | // NOTE: given a bit more time, I could make a more C++-style iterator out of this: 187 | const vec& bucket(int i) const { return table[i]; } 188 | }; 189 | 190 | //================================================================================================= 191 | } 192 | 193 | #endif 194 | -------------------------------------------------------------------------------- /casestudies/vehicleCollision/json_net_against_csv_robustness_verifier.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # 3 | # This program takes a JSON file that describes a network for classification that has been learned from a CSV file 4 | # and the CSV file itself. It then checks if the Network has an accurracy of 1 (i.e., whether every data point is classified correctly) 5 | # and what the robustness against deviations in every input dimension is. 6 | # 7 | # It uses other tools from the "tools" directory to achieve this, including the RLV compressor. 8 | import os, sys,subprocess, time 9 | 10 | VERIFIER = "/../../src/planet" 11 | ABORT_ERROR_MARGIN = 0.002 12 | START_ERROR_MARGIN = 0.05 13 | 14 | if len(sys.argv)<3: 15 | print >>sys.stderr, "Error: Need two file names as parameters: the JSON-File and the CSV file." 16 | sys.exit(1) 17 | 18 | # Read CSV file 19 | with open(sys.argv[2],"r") as inFile: 20 | csvHeader = inFile.readline() 21 | csvLines = [a.strip() for a in inFile.readlines()] 22 | 23 | # Process CSV file 24 | nofClasses = 0 25 | for i in range(0,len(csvLines)): 26 | parts = csvLines[i].split(",") 27 | parts[-1] = int(parts[-1]) 28 | nofClasses = max(nofClasses,parts[-1]) 29 | for j in range(0,len(parts)-1): 30 | parts[j] = float(parts[j]) 31 | csvLines[i] = parts 32 | 33 | 34 | # Translate to RLV without main constraint 35 | tmpFilenameUnpreprocessedRLVFile = "/tmp/RLVUnpreprocessed-"+str(os.getpid())+".rlv" 36 | tmpFilenamePreprocessedRLVFile = "/tmp/RLVProcessed-"+str(os.getpid())+".rlv" 37 | scriptPath = os.path.dirname(sys.argv[0]) 38 | translatorToRLVProcess = subprocess.Popen([scriptPath+"/../../tools/json_network_to_rlv_translator.py",sys.argv[1]],stdout=subprocess.PIPE) 39 | allRLVLines = [a.strip() for a in translatorToRLVProcess.stdout.readlines()] 40 | assert translatorToRLVProcess.wait()==0 41 | 42 | nofCSVLinesProcessed = 0 43 | for csvLine in csvLines: 44 | nofCSVLinesProcessed += 1 45 | if nofCSVLinesProcessed>100: 46 | print >>sys.stderr, "Processed 100 cases." 47 | sys.exit(0) 48 | print " ".join([str(a) for a in csvLine]),"->", 49 | sys.stdout.flush() 50 | 51 | # Build a "precise instance" 52 | isAnySAT = False 53 | for j in range(0,nofClasses+1): 54 | if j!=csvLine[-1]: 55 | with open(tmpFilenameUnpreprocessedRLVFile,"w") as outFile: 56 | for line in allRLVLines: 57 | outFile.write(line+"\n") 58 | for i in range(0,len(csvLine)-1): 59 | outFile.write("Assert <= "+str(csvLine[i])+" 1.0 inX"+str(i)+"\n") 60 | outFile.write("Assert >= "+str(csvLine[i])+" 1.0 inX"+str(i)+"\n") 61 | outFile.write("Assert >= 0.0 -1.0 outX"+str(j)+" 1.0 outX"+str(csvLine[-1])+"\n") 62 | 63 | # Now Preprocess 64 | preprocessorProcess = subprocess.Popen([scriptPath+"/../../tools/rlvCompressor.py",tmpFilenameUnpreprocessedRLVFile],stdout=subprocess.PIPE) 65 | allPreprocessedLines = preprocessorProcess.stdout.readlines() 66 | assert preprocessorProcess.wait()==0 67 | with open(tmpFilenamePreprocessedRLVFile,"w") as outFile: 68 | for a in allPreprocessedLines: 69 | outFile.write(a) 70 | 71 | # Now check with the Checker.... 72 | modelCheckerProcess = subprocess.Popen([scriptPath+VERIFIER,tmpFilenamePreprocessedRLVFile],stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 73 | allMCLines = modelCheckerProcess.stdout.readlines() 74 | if modelCheckerProcess.wait()!=0: 75 | print >>sys.stderr, "Error executing verifier:" 76 | for a in allMCLines: 77 | print a 78 | sys.exit(1) 79 | isSAT = None 80 | for line in allMCLines: 81 | if line.startswith("SAT"): 82 | isSAT = True 83 | elif line.startswith("UNSAT"): 84 | isSAT = False 85 | sys.stdout.flush() 86 | assert not isSAT is None 87 | isAnySAT = isAnySAT or isSAT 88 | 89 | # Finally print result 90 | if isAnySAT: 91 | print "Found Error" 92 | else: 93 | print "OK,", 94 | sys.stdout.flush() 95 | 96 | # Now compute robustness 97 | errorMarginMin = 0.0 98 | errorMarginMax = START_ERROR_MARGIN 99 | while ((errorMarginMax-errorMarginMin) > ABORT_ERROR_MARGIN): 100 | 101 | errorMargin = (errorMarginMax+errorMarginMin)/2.0 102 | foundError = False 103 | for j in range(0,nofClasses+1): 104 | if j!=csvLine[-1]: 105 | with open(tmpFilenameUnpreprocessedRLVFile,"w") as outFile: 106 | for line in allRLVLines: 107 | outFile.write(line+"\n") 108 | for i in range(0,len(csvLine)-1): 109 | outFile.write("Assert <= "+str(csvLine[i]-errorMargin)+" 1.0 inX"+str(i)+"\n") 110 | outFile.write("Assert >= "+str(csvLine[i]+errorMargin)+" 1.0 inX"+str(i)+"\n") 111 | outFile.write("Assert >= 0.0 -1.0 outX"+str(j)+" 1.0 outX"+str(csvLine[-1])+"\n") 112 | 113 | 114 | # Now Preprocess 115 | preprocessorProcess = subprocess.Popen([scriptPath+"/../../tools/rlvCompressor.py",tmpFilenameUnpreprocessedRLVFile],stdout=subprocess.PIPE) 116 | allPreprocessedLines = preprocessorProcess.stdout.readlines() 117 | assert preprocessorProcess.wait()==0 118 | with open(tmpFilenamePreprocessedRLVFile,"w") as outFile: 119 | for a in allPreprocessedLines: 120 | outFile.write(a) 121 | 122 | 123 | # Now check with the Checker.... 124 | startingTime = time.time() 125 | modelCheckerProcess = subprocess.Popen([scriptPath+VERIFIER,tmpFilenamePreprocessedRLVFile],stdout=subprocess.PIPE,stderr=subprocess.STDOUT) 126 | allMCLines = modelCheckerProcess.stdout.readlines() 127 | timeDuration = time.time() - startingTime 128 | 129 | assert modelCheckerProcess.wait()==0 130 | isSAT = None 131 | for line in allMCLines: 132 | if line.startswith("SAT"): 133 | isSAT = True 134 | elif line.startswith("UNSAT"): 135 | isSAT = False 136 | sys.stdout.flush() 137 | assert not isSAT is None 138 | foundError = foundError or isSAT 139 | 140 | # Write benchmark file if applicable. 141 | # if (timeDuration<6000.0) and (timeDuration>0.05): 142 | if True: 143 | satPostfix = "SAT" 144 | if isSAT==False: 145 | satPostfix = "UNSAT" 146 | os.system("cp "+tmpFilenamePreprocessedRLVFile+" /tmp/reluBenchmark"+str(timeDuration)+"s_"+satPostfix+".rlv") 147 | 148 | 149 | if foundError: 150 | errorMarginMax = errorMargin 151 | else: 152 | errorMarginMin = errorMargin 153 | print "Error Margin >=",errorMarginMin 154 | -------------------------------------------------------------------------------- /casestudies/MNIST/prodNetwork.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import os, glob, sys, subprocess 3 | import PIL.Image 4 | from joblib import Parallel, delayed 5 | 6 | if len(sys.argv)<3: 7 | print >>sys.stderr, "Error: Wanted an RLV filename, a mode, and parameters for the modes" 8 | print >>sys.stderr, "Modes are:" 9 | print >>sys.stderr, "- GIVE - Obtain an arbitrary image that yields the number" 10 | print >>sys.stderr, "- GIVESTRONG - Obtain an arbitrary image that strongly yields the number, i.e., the other digit values in the output layer must be at least smaller." 11 | print >>sys.stderr, "- ROBUST - Obtain a digit image that is close to a given one, that resolves to the given target digit, where every pixel is at most maxDifferencePerPixel away from the initial image, and the maximal noise difference between two adjacent pixels is maxUnsmoothnessInNoise. The last two parameters should be >=0 and <=1 (such as, e.g., 0.05 for 5% deviation)" 12 | sys.exit(1) 13 | 14 | rlvFile = sys.argv[1] 15 | mode = sys.argv[2] 16 | 17 | # Read RLV Lines 18 | with open(rlvFile,"r") as inRLV: 19 | rlvLines = inRLV.readlines() 20 | 21 | 22 | if mode=="ANY": 23 | 24 | # Set the boundaries 25 | verifierProcess = subprocess.Popen("../../src/planet /dev/stdin",shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) 26 | for a in rlvLines: 27 | verifierProcess.stdin.write(a) 28 | for i in range(0,28*28): 29 | verifierProcess.stdin.write("Assert <= 0.0 1.0 inX"+str(i)+"\n") 30 | verifierProcess.stdin.write("Assert >= 0.0 1.0 inX"+str(i)+"\n") 31 | 32 | verifierProcess.stdin.close() 33 | 34 | foundSATLine = False 35 | foundValuationLine = False 36 | values = {} 37 | for a in verifierProcess.stdout.readlines(): 38 | sys.stdout.write(a) 39 | a = a.strip() 40 | if a=="SAT": 41 | foundSATLine = True 42 | elif a=="Valuation:": 43 | foundValuationLine = True 44 | elif a.startswith("- ") and foundValuationLine: 45 | parts = a.split(" ") 46 | assert parts[0]=="-" 47 | assert parts[3]=="/" 48 | values[parts[1][0:len(parts[1])-1]] = float(parts[2]) 49 | 50 | assert verifierProcess.wait()==0 51 | 52 | if not foundSATLine: 53 | print "No digit found." 54 | else: 55 | outFileName = "/tmp/outImage"+str(os.getpid())+"-any.png" 56 | outImage = PIL.Image.new("L", (28, 28)) 57 | for y in range(0,28): 58 | for x in range(0,28): 59 | outImage.putpixel((x,y),int(256*values["inX"+str(y*28+x)])) 60 | 61 | outImage.save(outFileName) 62 | print "Result is found in image file:",outFileName 63 | 64 | 65 | # Give mode 66 | elif mode=="GIVE" or mode=="GIVESTRONG": 67 | 68 | if len(sys.argv)<4: 69 | print >>sys.stderr, "Error: GIVE and GIVESTRING mode requires a digit number." 70 | sys.exit(1) 71 | digit = int(sys.argv[3]) 72 | 73 | if mode=="GIVESTRONG": 74 | if len(sys.argv)<5: 75 | print >>sys.stderr, "Error: GIVESTRING requires a minimum difference." 76 | sys.exit(1) 77 | minDifference = -1*float(sys.argv[4]) 78 | else: 79 | minDifference = -0.0000001 80 | 81 | 82 | # Set the boundaries 83 | verifierProcess = subprocess.Popen("../../src/planet /dev/stdin",shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) 84 | for a in rlvLines: 85 | verifierProcess.stdin.write(a) 86 | for i in range(0,28*28): 87 | verifierProcess.stdin.write("Assert <= 0.0 1.0 inX"+str(i)+"\n") 88 | verifierProcess.stdin.write("Assert >= 1.0 1.0 inX"+str(i)+"\n") 89 | 90 | # Set the output 91 | for i in range(0,10): 92 | if i!=digit: 93 | verifierProcess.stdin.write("Assert >= "+str(minDifference)+" 1.0 outX"+str(i)+" -1.0 outX"+str(digit)+"\n") 94 | verifierProcess.stdin.close() 95 | 96 | foundSATLine = False 97 | foundValuationLine = False 98 | values = {} 99 | for a in verifierProcess.stdout.readlines(): 100 | sys.stdout.write(a) 101 | a = a.strip() 102 | if a=="SAT": 103 | foundSATLine = True 104 | elif a=="Valuation:": 105 | foundValuationLine = True 106 | elif a.startswith("- ") and foundValuationLine: 107 | parts = a.split(" ") 108 | assert parts[0]=="-" 109 | assert parts[3]=="/" 110 | values[parts[1][0:len(parts[1])-1]] = float(parts[2]) 111 | 112 | assert verifierProcess.wait()==0 113 | 114 | if not foundSATLine: 115 | print "No digit found." 116 | else: 117 | outFileName = "/tmp/outImage"+str(os.getpid())+"-"+str(digit)+str(minDifference)+".png" 118 | outImage = PIL.Image.new("L", (28, 28)) 119 | for y in range(0,28): 120 | for x in range(0,28): 121 | outImage.putpixel((x,y),int(256*values["inX"+str(y*28+x)])) 122 | 123 | outImage.save(outFileName) 124 | print "Result is found in image file:",outFileName 125 | 126 | 127 | # ROBUST mode 128 | elif mode=="ROBUST": 129 | 130 | if len(sys.argv)<7: 131 | print >>sys.stderr, "Error: ROBUST needs many parameters." 132 | sys.exit(1) 133 | digitFile = sys.argv[3] 134 | targetDigit = int(sys.argv[4]) 135 | maxDifferencePerPixel = float(sys.argv[5]) 136 | maxUnsmoothnessInNoise = float(sys.argv[6]) 137 | 138 | # Read image file 139 | im = PIL.Image.open(digitFile) #Can be many different formats. 140 | pix = im.load() 141 | assert im.size==(28,28) 142 | pixels = [pix[x,y] for y in range(0,28) for x in range(0,28)] 143 | 144 | # Set the boundaries 145 | verifierProcess = subprocess.Popen("../../src/planet /dev/stdin",shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) 146 | for a in rlvLines: 147 | verifierProcess.stdin.write(a) 148 | for i in range(0,28*28): 149 | # Outermost pixels need to be excluded 150 | x = i % 28 151 | y = int(i / 28) 152 | if x<3 or x>24 or y<3 or y>24: 153 | border = 0.0 154 | else: 155 | border = maxDifferencePerPixel 156 | mini = max(0.0,pixels[i]/256.0-border) 157 | maxi = min(1.0,pixels[i]/256.0+border) 158 | verifierProcess.stdin.write("Assert <= "+str(mini)+" 1.0 inX"+str(i)+"\n") 159 | verifierProcess.stdin.write("Assert >= "+str(maxi)+" 1.0 inX"+str(i)+"\n") 160 | 161 | # Set the output 162 | for i in range(0,10): 163 | if i!=targetDigit: 164 | verifierProcess.stdin.write("Assert >= -0.000001 1.0 outX"+str(i)+" -1.0 outX"+str(targetDigit)+"\n") 165 | 166 | # Set the smoothness 167 | if maxUnsmoothnessInNoise<1.0: 168 | for x in range(0,28): 169 | for y in range(0,28): 170 | # Smooth down 171 | if (y<27): 172 | pixelDiff = (pixels[y*28+x]-pixels[(y+1)*28+x])/256.0 173 | verifierProcess.stdin.write("Assert <= "+str(pixelDiff-maxUnsmoothnessInNoise)+" 1.0 inX"+str(y*28+x)+" -1.0 inX"+str((y+1)*28+x)+"\n") 174 | verifierProcess.stdin.write("Assert >= "+str(pixelDiff+maxUnsmoothnessInNoise)+" 1.0 inX"+str(y*28+x)+" -1.0 inX"+str((y+1)*28+x)+"\n") 175 | # Smooth right 176 | if (x<27): 177 | pixelDiff = (pixels[y*28+x]-pixels[y*28+x+1])/256.0 178 | verifierProcess.stdin.write("Assert <= "+str(pixelDiff-maxUnsmoothnessInNoise)+" 1.0 inX"+str(y*28+x)+" -1.0 inX"+str(y*28+x+1)+"\n") 179 | verifierProcess.stdin.write("Assert >= "+str(pixelDiff+maxUnsmoothnessInNoise)+" 1.0 inX"+str(y*28+x)+" -1.0 inX"+str(y*28+x+1)+"\n") 180 | 181 | # Done with the input instance 182 | verifierProcess.stdin.close() 183 | 184 | foundSATLine = False 185 | foundValuationLine = False 186 | values = {} 187 | for a in verifierProcess.stdout.readlines(): 188 | sys.stdout.write(a) 189 | a = a.strip() 190 | if a=="SAT": 191 | foundSATLine = True 192 | elif a=="Valuation:": 193 | foundValuationLine = True 194 | elif a.startswith("- ") and foundValuationLine: 195 | parts = a.split(" ") 196 | assert parts[0]=="-" 197 | assert parts[3]=="/" 198 | values[parts[1][0:len(parts[1])-1]] = float(parts[2]) 199 | 200 | assert verifierProcess.wait()==0 201 | 202 | if not foundSATLine: 203 | print "No digit found." 204 | else: 205 | outFileName = "/tmp/outImage"+str(os.getpid())+"-"+str(targetDigit)+"-"+str(maxDifferencePerPixel)+"-"+str(maxUnsmoothnessInNoise)+".png" 206 | outImage = PIL.Image.new("L", (28, 28)) 207 | for y in range(0,28): 208 | for x in range(0,28): 209 | outImage.putpixel((x,y),int(256*values["inX"+str(y*28+x)])) 210 | 211 | outImage.save(outFileName) 212 | print "Result is found in image file:",outFileName 213 | 214 | 215 | 216 | else: 217 | # Unknown mode. 218 | print >>sys.stderr, "Unknown 'prodNetwork' operation mode: ",mode 219 | sys.exit(1) 220 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PLANET: a Piece-wise LineAr feed-forward NEural network verification Tool 2 | =========================================================================== 3 | 4 | PLANET is a tool to verify feed-forward neural networks against convex specifications. The tool implements the approach described in [this paper](https://arxiv.org/abs/1705.01320). 5 | 6 | This documentation is work in progress, but the tool is already usable. If you have questions, please leave a note under https://github.com/progirep/planet/issues. It shall be noted that verifying neural networks is computationally difficult, hence don't expect verification to scale as well as learning. However, Planet has been successfully used for some case studies. The node types supported in the Network are ReLU nodes, MaxPool nodes, linear nodes (also called InnerProduct node in Caffe), and variants of it that are equivalent from the verification point of view (such as convolutional layer nodes). 7 | 8 | Part of this repository are scripts to translate models that have been learned with the [Caffe](http://caffe.berkeleyvision.org) framework into input files for the verifier. Note that these scripts currently support only a limited set of layer types and only certain architecture styles -- please look at the example network .prototxt files for supported features. 9 | 10 | 11 | License 12 | ------- 13 | 14 | Planet itself is available under GPLv3 license, as it uses the GNU Linear Programming toolkit, which is also under GPLv2. 15 | 16 | This repository contains some modified network definition files from the [Caffe](http://caffe.berkeleyvision.org) neural network learning framework, which is licensed under the BSD 2-Clause license. The modifications are available under the same license. 17 | 18 | The Planet tool uses a modified version of [Minisat v.2.2.0](http://minisat.se/MiniSat.html), which itself is available under the MIT license. If you are interested in Minisat, visit http://minisat.se/MiniSat.html and get the solver from there. This repository only contains the Minisat parts that were actually used in Planet. 19 | 20 | 21 | Preparation: 22 | ------------ 23 | 24 | The verifier is written in C++ (using some C++14 features), and the scripts that accompany the verification tool are written in Python 2. We assume a Linux system for the instructions in the documentation. You may be able to get the verification tool and the scripts running on Windows with some modification, but this has not been tested. 25 | 26 | Before we can use the tool, some preparation has to be done: 27 | 28 | - Not part of this repository are two scripts to translate a neural network description in the "prototxt" format (as produced by Caffe) into a json file, and a (modified) script to generate a database in "HDF5" format from comma-separated-value files. To obtain those, run the following command from the terminal in the PLANET directory: 29 | 30 | cd tools; wget https://gist.github.com/progirep/fd7d2dc120862faa984a70f503611013/raw/260e1e76cebd0ea58bf1a03b64c3f1e0002fc677/csv_to_hdf5_supervised_classification.py; wget https://raw.githubusercontent.com/vadimkantorov/caffemodel2json/3a8fd443bf1596dad5f517aecdef08a81bf73bfe/caffemodel2json.py 31 | 32 | - Then, some packages have to be installed in order to build "PLANET" (and to use the python scripts that come with it). For Ubuntu 17.04, the following packages are known to be requirements: 33 | - libglpk-dev 34 | - qt5-qmake 35 | - valgrind 36 | - libltdl-dev 37 | - protobuf-compiler 38 | 39 | The tool can then be compiled by running: 40 | 41 | cd src; qmake Tool.pro; makes 42 | 43 | Some scripts in this repository need the root path of the Caffe neural network learning framework, or the root path of the Yices SMT solver. The following environment variables should point to these: 44 | 45 | - The $CAFFE environment variable should be set to the Caffe root path. 46 | - The $YICES environment variable should be set to the Yices root path. 47 | 48 | 49 | PLANET specification files 50 | -------------------------- 51 | 52 | Planet uses a special neural network verification scenario description format as input file. It consists of a neural network description and a specification. The file format is text-based and independent of any neural network framework. While we provide scripts for Caffe to translate networks to input files, it should be possible to write similar scripts for other frameworks, such as TensorFlow. 53 | 54 | The input files are also pretty low-level -- nodes in the network are described individually, with all their weights. Every node description and specification part is given on an individual line in the input file. The following lines constitute a simple example specification file that features all node types supported by PLANET. 55 | 56 | Input inX0 57 | Input inX1 58 | Input inX2 59 | ReLU relu1 1.0 -0.5 inX0 -0.5 inX1 60 | MaxPool maxi inX2 relu1 61 | Linear lina 0.2 0.3 relu1 0.4 maxi 62 | Assert <= 0.0 1.0 inX0 63 | Assert >= 1.0 1.0 inX0 64 | Assert <= 0.0 1.0 inX1 65 | Assert >= 1.0 1.0 inX1 66 | Assert <= 0.0 1.0 inX2 67 | Assert >= 1.0 1.0 inX2 68 | Assert >= 0.6 1.0 lina 0.1 inX0 69 | Assert <= 0.4 1.0 lina 0.1 inX0 70 | 71 | The first three lines define Input nodes for the network. The line afterwards defines a ReLU node, with bias 1.0 and two incoming edges from inX0 and inX, each weighted -0.5. The next node is a MaxPool node, called maxi, with two incoming edges from inX2 and relu1. The node afterwards is a linear node called "lina", with a bias of 0.2 and two edges from relu1 and maxi, weighted 0.3 and 0.4. 72 | 73 | The lines afterwards are the specification constraints. Every line is of the form "Assert (operation) (constant) (linear parts)", and requires the verification tool to only consider network node valuations for which the verification condition "(constant) (operation) (linear parts)" holds. So the first "Assert" statement requires 0 to be less than or equal to 1.0 times inX0, and the second one requires 1.0 to be greater than or equal to 1.0 times inX0. Together, the constrain inX0 to be in the interval from 0 to 1. 74 | 75 | The later constraint lines follow a similar form and restrict the values of the other input nodes. Note that Planet requires all input node values to be bounded - the tool will otherwise abort with an error message. The final two constraints require 1.0 times lina + 0.1 times inX0 to be between 0.4 and 0.6. 76 | 77 | It suffices to run "path/to/planet inputFile.rlv" to start verifying an input file. The result will either be "UNSAT" or "SAT", depending on whether a neural network input has been found for which the network behavior satisfies all given constraints. Running Planet on this input file (by just passing its file name as parameter to the tool) yields a lot of debug output and concludes with the following result: 78 | 79 | SAT 80 | 81 | Valuation: 82 | - inX0: 1 / 1 83 | - inX1: 0.714286 / 0.714286 84 | - inX2: 0.142857 / 0.142857 85 | - relu1: 0.142857 / 0.142857 86 | - maxi: 0.142857 / 0.142857 87 | - lina: 0.3 / 0.3 88 | Literals: -4 2 3 89 | Total error: 1.11022e-16 90 | 91 | The first line states that there is a node value assignment function for the network that satisfies all "Assert" constraints. The lines below state how it looks like, including the input and output nodes of the network. The "Literals" line tells us the assignment to the SAT solving variables - the SAT solver is used internally in the search process. The final line "Total Error" gives the sum of deviations between the computed node values and the ones returned by the linear programming library employed in Planet. These values should be very low, otherwise the network weights were so high (or low) that the numerical accurracy of the solution process was to low to obtain good results. 92 | 93 | In case there is no node value assignment function for the network that satisfies all constraints, the final output of the tool will be "UNSAT". 94 | 95 | 96 | Translating a Caffe model to an input file for the verifier: 97 | ------------------------------------------------------------ 98 | The RLV file format used by Planet is pretty low-level, as it lists the artificial neurons one-by-one. The Caffe deep learning framework on the other hand operates on a layer-by-layer basis and also stores learned network weights in this way. Thus, Caffe network models need to be preprocessed in order to be verified. The planet distribution come with a few Python scripts to make this work. 99 | 100 | For this to work, a few requirements need to be met: 101 | 102 | 1. Currently, the only Caffe layer types supported are "Split", "InnerProduct", "ReLU", "Convolution", "Pooling" (using Max-Pooling), "HDF5Data", "Data", "Reshape", and "Pooling". There may be other layer types, but they must not be backwards-reachable from the "Accuracy" layer (of which there must be exactly one in the training phase). 103 | 2. Caffe allows InnerProduct and ReLU layers to be connected to each other (so that when plotting the network architecture, we get a small loop). This is not allowed - rather, the output of an InnerProduct layer can be sent through a ReLU layer. 104 | 3. The translation script needs to know the dimensions of all layers, which it cannot always infer from the description of the output network. Whenever the script yields an error due to this problem, a Reshape layer should be added immediately after the data layer to rehape it to the same shape as before. This causes shape information to be written to the file containing the learned network, which is then interpreted by the translator scripts. 105 | 4. InnerProduct and ReLU layers currently only operate on one-dimensional layers. If they should be used on n-dimensional layers for n>1 (such as in image recognition applications), they need to be reshaped before the InnerProduct or ReLU layers. They can be reshaped back in the network definition. 106 | 5. MaxPool layers assume a three-dimensional input (x-dimension of images, y-dimension of images, and color/feature dimension). 107 | 108 | There are two network description files as examples in the repository, which let Caffe output network models that the scripts that come with Planet can process: 109 | 110 | - casestudies/vehicleCollision/caffe\_net\_with\_pooling.prototxt 111 | - casestudies/MNIST/lenet\_train\_test.prototxt 112 | 113 | Training the network can be done as usual with Caffe - by passing a separate .prototxt file with the parameters for learning (learning rate, which network description file is being used, etc.) to the caffe command line utility. 114 | 115 | 116 | Running the Collision Avoidance Benchmarks: 117 | ------------------------------------------- 118 | All files for the collision avoidance benchmark can be found in the folder "casestudies/vehicleCollision". 119 | 120 | The script "generator.py" can be run with "./generator.py" and is generating collision yes/no cases. They are stored in the file "collisions.csv". The GIT repository already contains the collision cases used as benchmarks, but by letting the "generator.py" script run, more lines are added to the CSV file. 121 | 122 | Before the CSV file can be used in Caffe, it has to be brought into a compatible formar. The script "build_database.sh" builds the HDF5 version of "collisions.csv" 123 | 124 | Next is the training step. Script "./train.sh" starts Caffe on the task. The network structure is defined in "caffe_net_with_pooling.prototxt", while the file "caffe_solver_with_pooling.prototxt" stores Caffe's parameters. The result is put into the "snapshots" directory. 125 | 126 | The "verify.sh" script then starts the robustness verification process of the learned network (note that this only really makes sense if the network turned out to have an accurracy of 100 percent). It first translates the network to a JSON file. The JSON file is then used in the script "json_net_against_csv_robustness_verifier.py", which performs the robustness verification. The latter script translates the JSON network description to a .rlv network description as its first step of operation. 127 | 128 | Running the MNIST Examples: 129 | ------------------------------------------- 130 | 131 | After learning the network (by running the train.sh script), the following steps can be performed: 132 | 133 | - First, run "./testAccuracy.sh" in the casestudies/MNIST directory. The process can be aborted once the first digit results start coming in. 134 | - Then, run "../../tools/rlvCompressor.py testNetwork.rlv > testNetworkB.rlv" to get a slightly optimized version of the benchmark. 135 | - Then, run "./prodNetwork.py testNetworkB.rlv GIVESTRONG 2 " to obtain an image that is strongly classified as a 2. 136 | 137 | -------------------------------------------------------------------------------- /src/lpSolvers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __LP_SOLVERS_HPP____ 2 | #define __LP_SOLVERS_HPP____ 3 | 4 | #include 5 | #include 6 | 7 | //===================================================================================================== 8 | // LP Solving Library for the ReLu Verifier 9 | // 10 | // Written for the case that all variables in the LP problem have natural upper and lower bounds 11 | // 12 | // Usage notes: 13 | // - When adding constraints and an objective function, the first element of the array 14 | // supplied that is looked at is element no. 1, and not 0. However, when giving variable 15 | // numbers to the library, the first variable has number 0. 16 | //===================================================================================================== 17 | 18 | #ifdef USE_GLPK 19 | extern "C" { 20 | #include "glpk.h" 21 | } 22 | #else 23 | extern "C" { 24 | #include "lp_lib.h" 25 | } 26 | #endif 27 | 28 | class NumericalFailureException { 29 | public: 30 | NumericalFailureException() {} 31 | }; 32 | 33 | /** 34 | * @brief LPSolve Instance encapsulator 35 | */ 36 | #ifndef USE_GLPK 37 | #define LPREALTYPE REAL 38 | #define LPINFEASIBLE INFEASIBLE 39 | #define LPUNBOUNDED UNBOUNDED 40 | #define LPOPTIMUM OPTIMAL 41 | 42 | class LPProblem { 43 | private: 44 | lprec *lp; 45 | public: 46 | LPProblem(unsigned int nofColumns) { 47 | lp = make_lp(0,nofColumns); 48 | if (lp==NULL) throw "Out of memory for LP allocation."; 49 | for (unsigned int i=0;i= getInfinite()) throw "Error: Objective has an open upper bound"; 110 | return data; 111 | } 112 | double getInfinite() { 113 | return get_infinite(lp); 114 | } 115 | void writeLP(const char *filename) { 116 | if (write_lp(lp,const_cast(filename))==0) throw "Error writing LP instance to file."; 117 | } 118 | void setBounds(unsigned int varNumberWithoutPlusOne,double lower, double upper) { 119 | if (set_bounds(lp, varNumberWithoutPlusOne+1, lower, upper)==0) throw "Error setting variable bounds"; 120 | } 121 | double getSolutionVarValue(unsigned int varNumWithoutPlusOne) { 122 | return get_var_primalresult(lp,varNumWithoutPlusOne+1+get_Nrows(lp)); 123 | } 124 | }; 125 | #endif 126 | 127 | 128 | 129 | /** 130 | * @brief LPSolve Instance encapsulator 131 | */ 132 | #ifdef USE_GLPK 133 | #define LPREALTYPE double 134 | #define LPINFEASIBLE 12345 135 | #define LPUNBOUNDED 12346 136 | #define LPOPTIMUM 12347 137 | class LPProblem { 138 | private: 139 | glp_prob *lp; 140 | unsigned int nofVars; 141 | int *allVariables; 142 | public: 143 | LPProblem(unsigned int nofColumns) : allVariables(NULL) { 144 | lp = glp_create_prob(); 145 | glp_term_out(GLP_OFF); 146 | if (lp==NULL) throw "Out of memory for LP allocation."; 147 | glp_add_cols(lp, nofColumns); 148 | for (unsigned int i=1;i<=nofColumns;i++) { 149 | glp_set_col_bnds(lp, i, GLP_FR, 0.0, 0.0); 150 | } 151 | nofVars = nofColumns; 152 | allVariables = new int[nofVars+1]; 153 | for (unsigned int i=0;i<=nofVars;i++) { 154 | allVariables[i] = i; 155 | } 156 | } 157 | 158 | // Default constructor -- Yields an unsable LPProblem. 159 | LPProblem() { 160 | lp = 0; 161 | allVariables = 0; 162 | } 163 | 164 | // Copying of this object is not allowed. However, a move is ok. 165 | LPProblem(const LPProblem &other) = delete; 166 | LPProblem(LPProblem &&other) { 167 | lp = other.lp; 168 | nofVars = other.nofVars; 169 | allVariables = other.allVariables; 170 | other.lp = 0; 171 | other.allVariables = 0; 172 | } 173 | LPProblem& operator=(const LPProblem &other) = delete; 174 | LPProblem& operator=(LPProblem &&other) { 175 | if (lp!=NULL) glp_delete_prob(lp); 176 | if (allVariables!=NULL) delete[] allVariables; 177 | lp = other.lp; 178 | nofVars = other.nofVars; 179 | allVariables = other.allVariables; 180 | other.lp = 0; 181 | other.allVariables = 0; 182 | return *this; 183 | } 184 | 185 | ~LPProblem() { 186 | if (lp!=NULL) glp_delete_prob(lp); 187 | if (allVariables!=NULL) delete[] allVariables; 188 | } 189 | void addRowModeOn() { 190 | // Nothing to do 191 | } 192 | void addRowModeOff() { 193 | // Nothing to do 194 | } 195 | /** 196 | * @brief Adds a constraint 197 | * @param row pointer to an array of all factors. The array starts at index 1 and the value at position 0 is ignored. 198 | * @param constraint_type constraint_type Should be ROWTYPE_EQ, ROWTYPE_GEQ, or so on. 199 | * @param rh the right-hand-side (a constant) 200 | */ 201 | void addLEQConstraint(LPREALTYPE *coefficients, LPREALTYPE rh) { 202 | glp_add_rows(lp, 1); 203 | glp_set_row_bnds(lp, glp_get_num_rows(lp), GLP_UP, 0.0, rh); 204 | glp_set_mat_row(lp, glp_get_num_rows(lp), nofVars,allVariables,coefficients); 205 | } 206 | void addEQConstraint(LPREALTYPE *coefficients, LPREALTYPE rh) { 207 | glp_add_rows(lp, 1); 208 | glp_set_row_bnds(lp, glp_get_num_rows(lp), GLP_FX, rh, rh); 209 | glp_set_mat_row(lp, glp_get_num_rows(lp), nofVars,allVariables,coefficients); 210 | } 211 | void addGEQConstraint(LPREALTYPE *coefficients, LPREALTYPE rh) { 212 | glp_add_rows(lp, 1); 213 | glp_set_row_bnds(lp, glp_get_num_rows(lp), GLP_LO, rh, 0.0); 214 | glp_set_mat_row(lp, glp_get_num_rows(lp), nofVars,allVariables,coefficients); 215 | } 216 | void setMinim() { 217 | glp_set_obj_dir(lp, GLP_MIN); 218 | } 219 | void setMaxim() { 220 | glp_set_obj_dir(lp, GLP_MAX); 221 | } 222 | void setObjFn(LPREALTYPE *row) { 223 | for (unsigned int i=0;i 24 | #include 25 | #include 26 | #include 27 | 28 | #include "IntTypes.h" 29 | #include "Vec.h" 30 | #include "ParseUtils.h" 31 | 32 | namespace Minisat { 33 | 34 | //================================================================================================== 35 | // Top-level option parse/help functions: 36 | 37 | 38 | extern void parseOptions (int& argc, char** argv, bool strict = false); 39 | extern void printUsageAndExit(int argc, char** argv, bool verbose = false); 40 | extern void setUsageHelp (const char* str); 41 | extern void setHelpPrefixStr (const char* str); 42 | 43 | 44 | //================================================================================================== 45 | // Options is an abstract class that gives the interface for all types options: 46 | 47 | 48 | class Option 49 | { 50 | protected: 51 | const char* name; 52 | const char* description; 53 | const char* category; 54 | const char* type_name; 55 | 56 | static vec& getOptionList () { static vec options; return options; } 57 | static const char*& getUsageString() { static const char* usage_str; return usage_str; } 58 | static const char*& getHelpPrefixString() { static const char* help_prefix_str = ""; return help_prefix_str; } 59 | 60 | struct OptionLt { 61 | bool operator()(const Option* x, const Option* y) { 62 | int test1 = strcmp(x->category, y->category); 63 | return test1 < 0 || (test1 == 0 && strcmp(x->type_name, y->type_name) < 0); 64 | } 65 | }; 66 | 67 | Option(const char* name_, 68 | const char* desc_, 69 | const char* cate_, 70 | const char* type_) : 71 | name (name_) 72 | , description(desc_) 73 | , category (cate_) 74 | , type_name (type_) 75 | { 76 | getOptionList().push(this); 77 | } 78 | 79 | public: 80 | virtual ~Option() {} 81 | 82 | virtual bool parse (const char* str) = 0; 83 | virtual void help (bool verbose = false) = 0; 84 | 85 | friend void parseOptions (int& argc, char** argv, bool strict); 86 | friend void printUsageAndExit (int argc, char** argv, bool verbose); 87 | friend void setUsageHelp (const char* str); 88 | friend void setHelpPrefixStr (const char* str); 89 | }; 90 | 91 | 92 | //================================================================================================== 93 | // Range classes with specialization for floating types: 94 | 95 | 96 | struct IntRange { 97 | int begin; 98 | int end; 99 | IntRange(int b, int e) : begin(b), end(e) {} 100 | }; 101 | 102 | struct Int64Range { 103 | int64_t begin; 104 | int64_t end; 105 | Int64Range(int64_t b, int64_t e) : begin(b), end(e) {} 106 | }; 107 | 108 | struct DoubleRange { 109 | double begin; 110 | double end; 111 | bool begin_inclusive; 112 | bool end_inclusive; 113 | DoubleRange(double b, bool binc, double e, bool einc) : begin(b), end(e), begin_inclusive(binc), end_inclusive(einc) {} 114 | }; 115 | 116 | 117 | //================================================================================================== 118 | // Double options: 119 | 120 | 121 | class DoubleOption : public Option 122 | { 123 | protected: 124 | DoubleRange range; 125 | double value; 126 | 127 | public: 128 | DoubleOption(const char* c, const char* n, const char* d, double def = double(), DoubleRange r = DoubleRange(-HUGE_VAL, false, HUGE_VAL, false)) 129 | : Option(n, d, c, ""), range(r), value(def) { 130 | // FIXME: set LC_NUMERIC to "C" to make sure that strtof/strtod parses decimal point correctly. 131 | } 132 | 133 | operator double (void) const { return value; } 134 | operator double& (void) { return value; } 135 | DoubleOption& operator=(double x) { value = x; return *this; } 136 | 137 | virtual bool parse(const char* str){ 138 | const char* span = str; 139 | 140 | if (!match(span, "-") || !match(span, name) || !match(span, "=")) 141 | return false; 142 | 143 | char* end; 144 | double tmp = strtod(span, &end); 145 | 146 | if (end == NULL) 147 | return false; 148 | else if (tmp >= range.end && (!range.end_inclusive || tmp != range.end)){ 149 | fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name); 150 | exit(1); 151 | }else if (tmp <= range.begin && (!range.begin_inclusive || tmp != range.begin)){ 152 | fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name); 153 | exit(1); } 154 | 155 | value = tmp; 156 | // fprintf(stderr, "READ VALUE: %g\n", value); 157 | 158 | return true; 159 | } 160 | 161 | virtual void help (bool verbose = false){ 162 | fprintf(stderr, " -%-12s = %-8s %c%4.2g .. %4.2g%c (default: %g)\n", 163 | name, type_name, 164 | range.begin_inclusive ? '[' : '(', 165 | range.begin, 166 | range.end, 167 | range.end_inclusive ? ']' : ')', 168 | value); 169 | if (verbose){ 170 | fprintf(stderr, "\n %s\n", description); 171 | fprintf(stderr, "\n"); 172 | } 173 | } 174 | }; 175 | 176 | 177 | //================================================================================================== 178 | // Int options: 179 | 180 | 181 | class IntOption : public Option 182 | { 183 | protected: 184 | IntRange range; 185 | int32_t value; 186 | 187 | public: 188 | IntOption(const char* c, const char* n, const char* d, int32_t def = int32_t(), IntRange r = IntRange(INT32_MIN, INT32_MAX)) 189 | : Option(n, d, c, ""), range(r), value(def) {} 190 | 191 | operator int32_t (void) const { return value; } 192 | operator int32_t& (void) { return value; } 193 | IntOption& operator= (int32_t x) { value = x; return *this; } 194 | 195 | virtual bool parse(const char* str){ 196 | const char* span = str; 197 | 198 | if (!match(span, "-") || !match(span, name) || !match(span, "=")) 199 | return false; 200 | 201 | char* end; 202 | int32_t tmp = strtol(span, &end, 10); 203 | 204 | if (end == NULL) 205 | return false; 206 | else if (tmp > range.end){ 207 | fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name); 208 | exit(1); 209 | }else if (tmp < range.begin){ 210 | fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name); 211 | exit(1); } 212 | 213 | value = tmp; 214 | 215 | return true; 216 | } 217 | 218 | virtual void help (bool verbose = false){ 219 | fprintf(stderr, " -%-12s = %-8s [", name, type_name); 220 | if (range.begin == INT32_MIN) 221 | fprintf(stderr, "imin"); 222 | else 223 | fprintf(stderr, "%4d", range.begin); 224 | 225 | fprintf(stderr, " .. "); 226 | if (range.end == INT32_MAX) 227 | fprintf(stderr, "imax"); 228 | else 229 | fprintf(stderr, "%4d", range.end); 230 | 231 | fprintf(stderr, "] (default: %d)\n", value); 232 | if (verbose){ 233 | fprintf(stderr, "\n %s\n", description); 234 | fprintf(stderr, "\n"); 235 | } 236 | } 237 | }; 238 | 239 | 240 | // Leave this out for visual C++ until Microsoft implements C99 and gets support for strtoll. 241 | #ifndef _MSC_VER 242 | 243 | class Int64Option : public Option 244 | { 245 | protected: 246 | Int64Range range; 247 | int64_t value; 248 | 249 | public: 250 | Int64Option(const char* c, const char* n, const char* d, int64_t def = int64_t(), Int64Range r = Int64Range(INT64_MIN, INT64_MAX)) 251 | : Option(n, d, c, ""), range(r), value(def) {} 252 | 253 | operator int64_t (void) const { return value; } 254 | operator int64_t& (void) { return value; } 255 | Int64Option& operator= (int64_t x) { value = x; return *this; } 256 | 257 | virtual bool parse(const char* str){ 258 | const char* span = str; 259 | 260 | if (!match(span, "-") || !match(span, name) || !match(span, "=")) 261 | return false; 262 | 263 | char* end; 264 | int64_t tmp = strtoll(span, &end, 10); 265 | 266 | if (end == NULL) 267 | return false; 268 | else if (tmp > range.end){ 269 | fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name); 270 | exit(1); 271 | }else if (tmp < range.begin){ 272 | fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name); 273 | exit(1); } 274 | 275 | value = tmp; 276 | 277 | return true; 278 | } 279 | 280 | virtual void help (bool verbose = false){ 281 | fprintf(stderr, " -%-12s = %-8s [", name, type_name); 282 | if (range.begin == INT64_MIN) 283 | fprintf(stderr, "imin"); 284 | else 285 | fprintf(stderr, "%4" PRIi64, range.begin); 286 | 287 | fprintf(stderr, " .. "); 288 | if (range.end == INT64_MAX) 289 | fprintf(stderr, "imax"); 290 | else 291 | fprintf(stderr, "%4" PRIi64, range.end); 292 | 293 | fprintf(stderr, "] (default: %" PRIi64")\n", value); 294 | if (verbose){ 295 | fprintf(stderr, "\n %s\n", description); 296 | fprintf(stderr, "\n"); 297 | } 298 | } 299 | }; 300 | #endif 301 | 302 | //================================================================================================== 303 | // String option: 304 | 305 | 306 | class StringOption : public Option 307 | { 308 | const char* value; 309 | public: 310 | StringOption(const char* c, const char* n, const char* d, const char* def = NULL) 311 | : Option(n, d, c, ""), value(def) {} 312 | 313 | operator const char* (void) const { return value; } 314 | operator const char*& (void) { return value; } 315 | StringOption& operator= (const char* x) { value = x; return *this; } 316 | 317 | virtual bool parse(const char* str){ 318 | const char* span = str; 319 | 320 | if (!match(span, "-") || !match(span, name) || !match(span, "=")) 321 | return false; 322 | 323 | value = span; 324 | return true; 325 | } 326 | 327 | virtual void help (bool verbose = false){ 328 | fprintf(stderr, " -%-10s = %8s\n", name, type_name); 329 | if (verbose){ 330 | fprintf(stderr, "\n %s\n", description); 331 | fprintf(stderr, "\n"); 332 | } 333 | } 334 | }; 335 | 336 | 337 | //================================================================================================== 338 | // Bool option: 339 | 340 | 341 | class BoolOption : public Option 342 | { 343 | bool value; 344 | 345 | public: 346 | BoolOption(const char* c, const char* n, const char* d, bool v) 347 | : Option(n, d, c, ""), value(v) {} 348 | 349 | operator bool (void) const { return value; } 350 | operator bool& (void) { return value; } 351 | BoolOption& operator=(bool b) { value = b; return *this; } 352 | 353 | virtual bool parse(const char* str){ 354 | const char* span = str; 355 | 356 | if (match(span, "-")){ 357 | bool b = !match(span, "no-"); 358 | 359 | if (strcmp(span, name) == 0){ 360 | value = b; 361 | return true; } 362 | } 363 | 364 | return false; 365 | } 366 | 367 | virtual void help (bool verbose = false){ 368 | 369 | fprintf(stderr, " -%s, -no-%s", name, name); 370 | 371 | for (uint32_t i = 0; i < 32 - strlen(name)*2; i++) 372 | fprintf(stderr, " "); 373 | 374 | fprintf(stderr, " "); 375 | fprintf(stderr, "(default: %s)\n", value ? "on" : "off"); 376 | if (verbose){ 377 | fprintf(stderr, "\n %s\n", description); 378 | fprintf(stderr, "\n"); 379 | } 380 | } 381 | }; 382 | 383 | //================================================================================================= 384 | } 385 | 386 | #endif 387 | -------------------------------------------------------------------------------- /benchmarks/collisionDetection/reluBenchmark0.3205909729s_SAT.rlv: -------------------------------------------------------------------------------- 1 | Input inX0 2 | Input inX1 3 | Input inX2 4 | Input inX3 5 | Input inX4 6 | Input inX5 7 | ReLU relu1X0 -0.00770533969626 0.425551980734 inX1 -0.978725194931 inX0 0.323562651873 inX3 -0.748208045959 inX2 1.16365802288 inX5 0.462842822075 inX4 8 | ReLU relu1X1 0.163050115108 -1.73516130447 inX1 -0.403024703264 inX0 1.79504454136 inX3 -1.62804996967 inX2 -1.62756943703 inX5 1.16260421276 inX4 9 | ReLU relu1X2 0.0 -0.00936131738126 inX1 -0.000367225555237 inX0 -0.0123930452392 inX3 -0.0220121368766 inX2 0.0123939150944 inX5 0.0172470472753 inX4 10 | ReLU relu1X3 1.997371912 -0.56884264946 inX1 -1.91524398327 inX0 -2.40323376656 inX3 0.23108355701 inX2 -0.947540819645 inX5 -1.22519731522 inX4 11 | ReLU relu1X4 1.07717883587 1.1676659584 inX1 -1.24283909798 inX0 -0.396047174931 inX3 -2.16434001923 inX2 -0.408886402845 inX5 -2.67813634872 inX4 12 | ReLU relu1X5 0.17343826592 0.181639790535 inX1 -0.581120252609 inX0 -0.64011490345 inX3 0.404753178358 inX2 -0.483487933874 inX5 1.38076388836 inX4 13 | ReLU relu1X6 0.0 -0.00689489394426 inX1 -0.000427972030593 inX0 -0.0061044045724 inX3 -0.0140960309654 inX2 0.0018380060792 inX5 0.00859019160271 inX4 14 | ReLU relu1X7 -0.742009282112 -0.298721164465 inX1 1.29478132725 inX0 0.651425421238 inX3 0.0895936563611 inX2 0.0423422046006 inX5 0.148307666183 inX4 15 | ReLU relu1X8 -0.115423373878 0.685900568962 inX1 1.93089449406 inX0 -1.22263300419 inX3 -0.753214240074 inX2 0.0619786679745 inX5 -1.6351121664 inX4 16 | ReLU relu1X9 0.0 0.00137634028215 inX1 0.00524098146707 inX0 -0.0192849878222 inX3 -0.0235808435827 inX2 -0.022592831403 inX5 -0.000675619929098 inX4 17 | ReLU relu1X10 0.0 -0.0185358300805 inX1 -0.0119916889817 inX0 -0.020028449595 inX3 -0.0154279498383 inX2 -0.016379090026 inX5 0.0159496255219 inX4 18 | ReLU relu1X11 -0.78370398283 -0.0887623056769 inX1 -0.606863796711 inX0 0.967090904713 inX3 0.177570700645 inX2 -1.2135232687 inX5 2.60164833069 inX4 19 | ReLU relu1X12 0.548846662045 0.864908993244 inX1 0.0668454319239 inX0 -0.753415048122 inX3 1.34699356556 inX2 1.93251335621 inX5 -0.681420564651 inX4 20 | ReLU relu1X13 -0.0788166448474 -0.119499228895 inX1 0.150416091084 inX0 0.037571888417 inX3 0.03391116485 inX2 0.0300718322396 inX5 0.0967094302177 inX4 21 | ReLU relu1X14 -0.259192168713 1.87436282635 inX1 -0.554330527782 inX0 -1.11021459103 inX3 -0.824956774712 inX2 0.219117835164 inX5 -0.20582036674 inX4 22 | ReLU relu1X15 1.16056859493 -2.94967937469 inX1 2.14835357666 inX0 1.43194854259 inX3 -1.73117256165 inX2 0.264111965895 inX5 0.208737194538 inX4 23 | ReLU relu1X16 -0.0489889197052 0.00689587648958 inX1 -0.423297464848 inX0 0.0767475962639 inX3 0.073494695127 inX2 -0.112210214138 inX5 -0.570491492748 inX4 24 | ReLU relu1X17 -0.129528686404 -0.203352257609 inX1 1.08402097225 inX0 -0.834911823273 inX3 -0.707668423653 inX2 0.247991353273 inX5 -0.240675061941 inX4 25 | ReLU relu1X18 -1.00296258926 1.39118921757 inX1 -0.66294169426 inX0 -0.0554503202438 inX3 -0.189661204815 inX2 -1.08617722988 inX5 0.470066875219 inX4 26 | ReLU relu1X19 -0.697150945663 -0.912062466145 inX1 -0.868307471275 inX0 2.13373279572 inX3 3.01121354103 inX2 0.702499747276 inX5 0.13462087512 inX4 27 | ReLU relu1X20 0.0 -0.00638233637437 inX1 -0.0133408214897 inX0 -0.0157795976847 inX3 -0.013156812638 inX2 -0.00445888983086 inX5 0.0143963824958 inX4 28 | ReLU relu1X21 0.835042178631 -1.45171582699 inX1 3.2471768856 inX0 -1.20353543758 inX3 -0.364715337753 inX2 0.694153368473 inX5 -0.559342384338 inX4 29 | ReLU relu1X22 0.678784668446 2.04990959167 inX1 -2.52055335045 inX0 -0.892051935196 inX3 -2.30720424652 inX2 -0.711961388588 inX5 -0.314919382334 inX4 30 | ReLU relu1X23 -0.820165395737 -0.717385590076 inX1 -0.293614149094 inX0 1.96939122677 inX3 2.45270419121 inX2 0.0285975001752 inX5 0.283298283815 inX4 31 | ReLU relu1X24 -0.00352367199957 0.0112918540835 inX1 -0.0194084886461 inX0 -0.0196145884693 inX3 0.000732473796234 inX2 0.019015705213 inX5 -0.0203110277653 inX4 32 | ReLU relu1X25 -0.596717834473 0.171730518341 inX1 1.7623950243 inX0 0.257751911879 inX3 0.0750553235412 inX2 -0.800745069981 inX5 -0.279645591974 inX4 33 | ReLU relu1X26 -0.496275812387 -1.6829379797 inX1 2.78025984764 inX0 1.17823457718 inX3 2.92984175682 inX2 0.995428979397 inX5 0.53321903944 inX4 34 | ReLU relu1X27 -0.00271431682631 0.00621621869504 inX1 -0.0102649712935 inX0 -0.0073749711737 inX3 -0.00232430337928 inX2 0.0110377082601 inX5 -0.00946983881295 inX4 35 | ReLU relu1X28 -0.871306657791 1.45531868935 inX1 0.390670776367 inX0 0.309387534857 inX3 -0.471480876207 inX2 -1.02763831615 inX5 2.40831661224 inX4 36 | ReLU relu1X29 1.08917236328 0.260794758797 inX1 -0.705449640751 inX0 -2.7236187458 inX3 1.00783705711 inX2 0.248063161969 inX5 -0.65232527256 inX4 37 | ReLU relu1X30 -1.46118175983 2.39195823669 inX1 0.904803514481 inX0 -0.730318009853 inX3 0.880049049854 inX2 0.712868154049 inX5 0.913892924786 inX4 38 | ReLU relu1X31 0.0 -0.0189517997205 inX1 0.00132768705953 inX0 -0.0120694627985 inX3 -0.0165205504745 inX2 -0.0090703247115 inX5 -0.0113717345521 inX4 39 | ReLU relu1X32 -1.34767282009 -1.05237591267 inX1 1.8539005518 inX0 1.34944605827 inX3 5.46926450729 inX2 0.708325862885 inX5 -0.0294558051974 inX4 40 | ReLU relu1X33 -0.434490591288 -0.277234792709 inX1 0.223877891898 inX0 0.397379428148 inX3 -0.404961168766 inX2 -0.406214952469 inX5 0.349417716265 inX4 41 | ReLU relu1X34 -2.15188145638 4.04485225677 inX1 -0.431448847055 inX0 -0.446634471416 inX3 1.0480017662 inX2 -0.00445634359494 inX5 -0.0966049358249 inX4 42 | ReLU relu1X35 -0.00407106988132 -0.0185089353472 inX1 0.00325125502422 inX0 -0.00835816655308 inX3 -0.00515520060435 inX2 0.0178822875023 inX5 -0.0205950625241 inX4 43 | ReLU relu1X36 -0.0119612775743 -0.00393535755575 inX1 0.00174772075843 inX0 0.00727396132424 inX3 -0.0230750106275 inX2 -0.00189159135334 inX5 0.0259838290513 inX4 44 | ReLU relu1X37 -0.731101572514 -0.521424710751 inX1 2.24679780006 inX0 1.03144669533 inX3 -2.47750687599 inX2 0.531722068787 inX5 -0.830998361111 inX4 45 | ReLU relu1X38 -0.172267585993 -1.25004553795 inX1 0.32142239809 inX0 0.631538450718 inX3 2.67303180695 inX2 -1.4778059721 inX5 -0.0117573086172 inX4 46 | ReLU relu1X39 0.70444136858 -2.11956572533 inX1 0.341825067997 inX0 0.279247134924 inX3 0.359533041716 inX2 2.32777523994 inX5 0.0277868025005 inX4 47 | MaxPool pool1X0X0X0 relu1X0 relu1X1 relu1X2 relu1X3 48 | MaxPool pool1X0X0X1 relu1X2 relu1X3 relu1X4 relu1X5 49 | MaxPool pool1X0X0X2 relu1X4 relu1X5 relu1X6 relu1X7 50 | MaxPool pool1X0X0X3 relu1X6 relu1X7 relu1X8 relu1X9 51 | MaxPool pool1X0X0X4 relu1X8 relu1X9 relu1X10 relu1X11 52 | MaxPool pool1X0X0X5 relu1X10 relu1X11 relu1X12 relu1X13 53 | MaxPool pool1X0X0X6 relu1X12 relu1X13 relu1X14 relu1X15 54 | MaxPool pool1X0X0X7 relu1X14 relu1X15 relu1X16 relu1X17 55 | MaxPool pool1X0X0X8 relu1X16 relu1X17 relu1X18 relu1X19 56 | MaxPool pool1X0X0X9 relu1X18 relu1X19 relu1X20 relu1X21 57 | MaxPool pool1X0X0X10 relu1X20 relu1X21 relu1X22 relu1X23 58 | MaxPool pool1X0X0X11 relu1X22 relu1X23 relu1X24 relu1X25 59 | MaxPool pool1X0X0X12 relu1X24 relu1X25 relu1X26 relu1X27 60 | MaxPool pool1X0X0X13 relu1X26 relu1X27 relu1X28 relu1X29 61 | MaxPool pool1X0X0X14 relu1X28 relu1X29 relu1X30 relu1X31 62 | MaxPool pool1X0X0X15 relu1X30 relu1X31 relu1X32 relu1X33 63 | MaxPool pool1X0X0X16 relu1X32 relu1X33 relu1X34 relu1X35 64 | MaxPool pool1X0X0X17 relu1X34 relu1X35 relu1X36 relu1X37 65 | MaxPool pool1X0X0X18 relu1X36 relu1X37 relu1X38 relu1X39 66 | ReLU relu2X0 -0.00211276905611 -0.0167680978775 pool1X0X0X16 -0.0100319618359 pool1X0X0X17 -0.00543770845979 pool1X0X0X14 -0.0136471735314 pool1X0X0X15 0.00544194458053 pool1X0X0X12 0.00283113261685 pool1X0X0X13 -0.00646980339661 pool1X0X0X10 -0.0149113032967 pool1X0X0X11 0.000277536804788 pool1X0X0X18 -0.00547050312161 pool1X0X0X4 0.00965722277761 pool1X0X0X5 -0.00314164487645 pool1X0X0X6 0.00262131495401 pool1X0X0X7 -0.0139371883124 pool1X0X0X0 -0.0117555465549 pool1X0X0X1 0.0118925459683 pool1X0X0X2 -0.0023211245425 pool1X0X0X3 -0.00413575721905 pool1X0X0X8 -0.00542060192674 pool1X0X0X9 67 | ReLU relu2X1 0.930051267147 -0.35909435153 pool1X0X0X16 0.599014222622 pool1X0X0X17 -0.146365523338 pool1X0X0X14 -0.561448276043 pool1X0X0X15 0.719234764576 pool1X0X0X12 -0.388034075499 pool1X0X0X13 -0.558998644352 pool1X0X0X10 -0.477382898331 pool1X0X0X11 0.586802005768 pool1X0X0X18 0.240489766002 pool1X0X0X4 -0.987980782986 pool1X0X0X5 0.880404531956 pool1X0X0X6 -1.49782693386 pool1X0X0X7 -0.0588516965508 pool1X0X0X0 -0.571606338024 pool1X0X0X1 1.65079474449 pool1X0X0X2 -0.0989808738232 pool1X0X0X3 0.120151117444 pool1X0X0X8 1.11836397648 pool1X0X0X9 68 | ReLU relu2X2 0.48064750433 -0.689829826355 pool1X0X0X16 -0.0137706082314 pool1X0X0X17 -0.39030367136 pool1X0X0X14 0.00849942304194 pool1X0X0X15 0.894917368889 pool1X0X0X12 0.246981665492 pool1X0X0X13 -0.699603497982 pool1X0X0X10 -1.71710574627 pool1X0X0X11 -0.673752188683 pool1X0X0X18 0.176278740168 pool1X0X0X4 0.140991672873 pool1X0X0X5 0.618384122849 pool1X0X0X6 -0.179051890969 pool1X0X0X7 -0.442848592997 pool1X0X0X0 0.0496455356479 pool1X0X0X1 1.33427834511 pool1X0X0X2 -0.0341505073011 pool1X0X0X3 -1.03307497501 pool1X0X0X8 0.0355235487223 pool1X0X0X9 69 | ReLU relu2X3 -0.68002229929 0.673226952553 pool1X0X0X16 1.61801981926 pool1X0X0X17 0.667186141014 pool1X0X0X14 -0.345945626497 pool1X0X0X15 -1.46472978592 pool1X0X0X12 -0.913834571838 pool1X0X0X13 -0.171317994595 pool1X0X0X10 -0.151650026441 pool1X0X0X11 -0.760961890221 pool1X0X0X18 -0.135002657771 pool1X0X0X4 0.751482665539 pool1X0X0X5 0.952252745628 pool1X0X0X6 0.932196617126 pool1X0X0X7 1.78008031845 pool1X0X0X0 0.0751789659262 pool1X0X0X1 -0.353252470493 pool1X0X0X2 -0.0905419066548 pool1X0X0X3 -1.70057868958 pool1X0X0X8 -1.54268991947 pool1X0X0X9 70 | ReLU relu2X4 -0.000993702560663 -0.0102032152936 pool1X0X0X16 -0.000864396104589 pool1X0X0X17 0.00602678349242 pool1X0X0X14 -0.0120005309582 pool1X0X0X15 -0.0115594500676 pool1X0X0X12 -0.012119339779 pool1X0X0X13 0.0045363008976 pool1X0X0X10 -8.18230910227e-06 pool1X0X0X11 -0.00286158663221 pool1X0X0X18 -0.00612418260425 pool1X0X0X4 0.00898835249245 pool1X0X0X5 -0.00315074482933 pool1X0X0X6 -0.0104464432225 pool1X0X0X7 0.00151618360542 pool1X0X0X0 -0.00115575431846 pool1X0X0X1 -0.00717756245285 pool1X0X0X2 0.000666244945023 pool1X0X0X3 -0.00564216868952 pool1X0X0X8 0.00614798162133 pool1X0X0X9 71 | ReLU relu2X5 -0.332929223776 2.37426233292 pool1X0X0X16 -2.03670310974 pool1X0X0X17 -2.8912191391 pool1X0X0X14 1.52849149704 pool1X0X0X15 1.17873549461 pool1X0X0X12 1.37006962299 pool1X0X0X13 0.179084584117 pool1X0X0X10 -1.1598931551 pool1X0X0X11 2.76042580605 pool1X0X0X18 1.91608083248 pool1X0X0X4 1.67609345913 pool1X0X0X5 -2.62268400192 pool1X0X0X6 0.928763329983 pool1X0X0X7 -2.13156437874 pool1X0X0X0 0.513960957527 pool1X0X0X1 -2.15346550941 pool1X0X0X2 1.0520927906 pool1X0X0X3 1.86331820488 pool1X0X0X8 0.697883486748 pool1X0X0X9 72 | ReLU relu2X6 2.35051655769 -1.16184175014 pool1X0X0X16 -0.0613299719989 pool1X0X0X17 0.421689093113 pool1X0X0X14 -0.263244539499 pool1X0X0X15 0.344555318356 pool1X0X0X12 0.0316255427897 pool1X0X0X13 -2.50629043579 pool1X0X0X10 -1.70668935776 pool1X0X0X11 -0.249095007777 pool1X0X0X18 0.289316236973 pool1X0X0X4 1.30095112324 pool1X0X0X5 0.856586158276 pool1X0X0X6 -1.708091259 pool1X0X0X7 0.672471165657 pool1X0X0X0 0.460894107819 pool1X0X0X1 -0.248897403479 pool1X0X0X2 0.22223508358 pool1X0X0X3 0.281160831451 pool1X0X0X8 0.344686955214 pool1X0X0X9 73 | ReLU relu2X7 -0.747793495655 0.398894876242 pool1X0X0X16 1.37313473225 pool1X0X0X17 0.278879523277 pool1X0X0X14 -0.149582326412 pool1X0X0X15 -0.31207498908 pool1X0X0X12 0.0704577416182 pool1X0X0X13 -0.151936247945 pool1X0X0X10 -0.324735641479 pool1X0X0X11 0.237951368093 pool1X0X0X18 0.369472593069 pool1X0X0X4 -1.27846956253 pool1X0X0X5 0.889570593834 pool1X0X0X6 -0.316260635853 pool1X0X0X7 0.71803855896 pool1X0X0X0 -1.0855525732 pool1X0X0X1 0.654287040234 pool1X0X0X2 -0.344522356987 pool1X0X0X3 0.822935521603 pool1X0X0X8 1.31374585629 pool1X0X0X9 74 | ReLU relu2X8 -0.986371278763 -0.178143337369 pool1X0X0X16 1.37320578098 pool1X0X0X17 0.918277025223 pool1X0X0X14 -0.53895008564 pool1X0X0X15 -1.65199685097 pool1X0X0X12 -0.598373055458 pool1X0X0X13 -0.291583478451 pool1X0X0X10 0.444794863462 pool1X0X0X11 -1.24869203568 pool1X0X0X18 -0.732813775539 pool1X0X0X4 0.261008918285 pool1X0X0X5 1.80278527737 pool1X0X0X6 -0.134303182364 pool1X0X0X7 1.85704684258 pool1X0X0X0 0.623540520668 pool1X0X0X1 0.455230981112 pool1X0X0X2 -0.552643656731 pool1X0X0X3 -0.611319899559 pool1X0X0X8 -2.74322128296 pool1X0X0X9 75 | ReLU relu2X9 -6.36781915091e-05 0.000304907065583 pool1X0X0X16 -0.000854436715599 pool1X0X0X17 -0.00520235998556 pool1X0X0X14 -0.011434758082 pool1X0X0X15 -0.0129004782066 pool1X0X0X12 0.00349430507049 pool1X0X0X13 -0.00165601004846 pool1X0X0X10 -0.0113796694204 pool1X0X0X11 -0.0114006707445 pool1X0X0X18 0.0103476662189 pool1X0X0X4 0.00565689476207 pool1X0X0X5 -0.0108053041622 pool1X0X0X6 0.0072118951939 pool1X0X0X7 -0.00952114257962 pool1X0X0X0 -0.00449769059196 pool1X0X0X1 0.00849624536932 pool1X0X0X2 -0.00346445781179 pool1X0X0X3 0.00448209512979 pool1X0X0X8 -0.00106061587576 pool1X0X0X9 76 | ReLU relu2X10 0.255233615637 -0.381480574608 pool1X0X0X16 0.0285897199064 pool1X0X0X17 0.328787475824 pool1X0X0X14 -0.36847832799 pool1X0X0X15 -0.641218245029 pool1X0X0X12 -0.478239655495 pool1X0X0X13 -0.0069968146272 pool1X0X0X10 -0.0227739345282 pool1X0X0X11 -0.682260632515 pool1X0X0X18 -0.141913816333 pool1X0X0X4 -0.478864818811 pool1X0X0X5 -0.264536470175 pool1X0X0X6 0.596308290958 pool1X0X0X7 0.346717894077 pool1X0X0X0 0.126566499472 pool1X0X0X1 0.188611090183 pool1X0X0X2 -0.126221060753 pool1X0X0X3 0.0124475061893 pool1X0X0X8 -0.04133348912 pool1X0X0X9 77 | ReLU relu2X11 -0.355603575706 0.402410417795 pool1X0X0X16 0.592986106873 pool1X0X0X17 -0.201115906239 pool1X0X0X14 -0.190337076783 pool1X0X0X15 -0.510640621185 pool1X0X0X12 -0.0390233099461 pool1X0X0X13 0.749961316586 pool1X0X0X10 0.0191912688315 pool1X0X0X11 -0.310647159815 pool1X0X0X18 0.17132781446 pool1X0X0X4 -0.966048777103 pool1X0X0X5 0.336175918579 pool1X0X0X6 -0.19271287322 pool1X0X0X7 0.340436637402 pool1X0X0X0 -0.749889731407 pool1X0X0X1 0.540169596672 pool1X0X0X2 -0.568409442902 pool1X0X0X3 0.35270050168 pool1X0X0X8 0.815179109573 pool1X0X0X9 78 | ReLU relu2X12 0.0 -0.00832767225802 pool1X0X0X16 -0.00366391893476 pool1X0X0X17 0.0130585469306 pool1X0X0X14 -0.00603838358074 pool1X0X0X15 -0.00424641137943 pool1X0X0X12 -0.00824540108442 pool1X0X0X13 -0.0068019493483 pool1X0X0X10 -0.000334977026796 pool1X0X0X11 0.0072642378509 pool1X0X0X18 -0.00990438647568 pool1X0X0X4 0.00342006213032 pool1X0X0X5 -0.0125209083781 pool1X0X0X6 -0.00143784796819 pool1X0X0X7 -0.00225481181405 pool1X0X0X0 -0.00849202182144 pool1X0X0X1 -0.000823586713523 pool1X0X0X2 -0.00175395270344 pool1X0X0X3 -0.00317804492079 pool1X0X0X8 0.00587154971436 pool1X0X0X9 79 | ReLU relu2X13 0.0 -0.011082935147 pool1X0X0X16 -0.00977044925094 pool1X0X0X17 -0.00129137269687 pool1X0X0X14 0.00831097923219 pool1X0X0X15 -0.00879818759859 pool1X0X0X12 -0.00972574576735 pool1X0X0X13 -0.0062761050649 pool1X0X0X10 -0.00175052578561 pool1X0X0X11 0.0122373513877 pool1X0X0X18 -0.00342879327945 pool1X0X0X4 0.00337444711477 pool1X0X0X5 -0.0115696303546 pool1X0X0X6 -0.0114610707387 pool1X0X0X7 -0.00860353931785 pool1X0X0X0 -0.00688825780526 pool1X0X0X1 -0.013207770884 pool1X0X0X2 -0.00555723626167 pool1X0X0X3 -0.00504626985639 pool1X0X0X8 0.00148337567225 pool1X0X0X9 80 | ReLU relu2X14 -0.00300744315609 0.00371964811347 pool1X0X0X16 -0.00748305348679 pool1X0X0X17 0.00325666740537 pool1X0X0X14 -0.00818553008139 pool1X0X0X15 -0.00375646818429 pool1X0X0X12 -0.0123562868685 pool1X0X0X13 0.00314318318851 pool1X0X0X10 -0.00190438842401 pool1X0X0X11 -0.00467666005716 pool1X0X0X18 -0.0106420889497 pool1X0X0X4 -0.0136025790125 pool1X0X0X5 0.00922034680843 pool1X0X0X6 -0.00130823371001 pool1X0X0X7 8.90502851689e-05 pool1X0X0X0 0.006133351475 pool1X0X0X1 -0.00542199192569 pool1X0X0X2 -0.0107323583215 pool1X0X0X3 -0.00951135437936 pool1X0X0X8 -0.00227686366998 pool1X0X0X9 81 | ReLU relu2X15 -0.176535978913 -0.0176770277321 pool1X0X0X16 -0.130379706621 pool1X0X0X17 -0.410345822573 pool1X0X0X14 -0.0433257557452 pool1X0X0X15 -0.312845230103 pool1X0X0X12 -0.70596832037 pool1X0X0X13 0.199828967452 pool1X0X0X10 0.926399946213 pool1X0X0X11 -0.398421525955 pool1X0X0X18 -0.290224283934 pool1X0X0X4 -0.179846212268 pool1X0X0X5 -0.235930994153 pool1X0X0X6 -0.471221894026 pool1X0X0X7 0.809457957745 pool1X0X0X0 1.0689958334 pool1X0X0X1 0.438100516796 pool1X0X0X2 -0.0459677278996 pool1X0X0X3 0.156665533781 pool1X0X0X8 -0.400512248278 pool1X0X0X9 82 | ReLU relu2X16 -0.139173194766 0.526388525963 pool1X0X0X16 0.416673064232 pool1X0X0X17 -0.0640570670366 pool1X0X0X14 0.368198245764 pool1X0X0X15 -0.131311908364 pool1X0X0X12 -0.279185414314 pool1X0X0X13 -0.229648903012 pool1X0X0X10 0.0516070090234 pool1X0X0X11 -0.237098366022 pool1X0X0X18 -0.369061380625 pool1X0X0X4 -0.11653419584 pool1X0X0X5 -0.233986124396 pool1X0X0X6 0.0886740460992 pool1X0X0X7 0.434254616499 pool1X0X0X0 0.341647446156 pool1X0X0X1 -0.0467130988836 pool1X0X0X2 0.0303373988718 pool1X0X0X3 0.283620357513 pool1X0X0X8 -0.349927395582 pool1X0X0X9 83 | ReLU relu2X17 -0.0148857617751 0.0287718307227 pool1X0X0X16 -0.0923720374703 pool1X0X0X17 0.0421522185206 pool1X0X0X14 0.073689378798 pool1X0X0X15 0.0291165020317 pool1X0X0X12 0.0904093533754 pool1X0X0X13 -0.034650593996 pool1X0X0X10 -0.091021925211 pool1X0X0X11 0.0259976200759 pool1X0X0X18 -0.0151482895017 pool1X0X0X4 0.146342054009 pool1X0X0X5 -0.0273102000356 pool1X0X0X6 -0.00108325609472 pool1X0X0X7 0.0488103441894 pool1X0X0X0 -0.0181279387325 pool1X0X0X1 -0.0719872117043 pool1X0X0X2 -0.0166891142726 pool1X0X0X3 -0.00461307773367 pool1X0X0X8 -0.0254984740168 pool1X0X0X9 84 | ReLU relu2X18 -0.47851973772 -1.2299683094 pool1X0X0X16 -0.838822722435 pool1X0X0X17 -0.316068828106 pool1X0X0X14 -0.539191305637 pool1X0X0X15 -0.501975655556 pool1X0X0X12 0.252721905708 pool1X0X0X13 1.36553764343 pool1X0X0X10 1.04609847069 pool1X0X0X11 -1.17921805382 pool1X0X0X18 -0.243340715766 pool1X0X0X4 1.46329593658 pool1X0X0X5 0.318324506283 pool1X0X0X6 0.693471610546 pool1X0X0X7 -0.99070250988 pool1X0X0X0 0.664568066597 pool1X0X0X1 -0.706344544888 pool1X0X0X2 0.244342118502 pool1X0X0X3 0.181315600872 pool1X0X0X8 0.177134156227 pool1X0X0X9 85 | Linear ip2X0 -0.105323210359 -0.00796643085778 relu2X0 -2.00408577919 relu2X1 -1.95536220074 relu2X2 2.97320175171 relu2X3 -0.0097716813907 relu2X4 4.58163309097 relu2X5 -3.20851206779 relu2X6 -1.99810171127 relu2X7 3.46907758713 relu2X8 0.00670911418274 relu2X9 1.09451031685 relu2X10 -1.42950892448 relu2X11 -0.00646871747449 relu2X12 0.00956485699862 relu2X13 -0.00773688452318 relu2X14 1.44270324707 relu2X15 0.833081662655 relu2X16 0.161857798696 relu2X17 2.23075556755 relu2X18 86 | Linear ip2X1 0.105313919485 0.0229359231889 relu2X0 2.00725245476 relu2X1 1.94528210163 relu2X2 -2.97571539879 relu2X3 0.00466247182339 relu2X4 -4.58863401413 relu2X5 3.20820689201 relu2X6 1.9868901968 relu2X7 -3.48216128349 relu2X8 -0.0112616531551 relu2X9 -1.08817493916 relu2X10 1.43029725552 relu2X11 -0.00300858076662 relu2X12 -0.0119460858405 relu2X13 0.000313411379466 relu2X14 -1.41833353043 relu2X15 -0.843563973904 relu2X16 -0.177298650146 relu2X17 -2.2320356369 relu2X18 87 | Linear outX0 0.0 1.0 ip2X0 88 | Linear outX1 0.0 1.0 ip2X1 89 | Assert <= 0.323206628805 1.0 inX0 90 | Assert >= 0.341956628805 1.0 inX0 91 | Assert <= 0.703902731167 1.0 inX1 92 | Assert >= 0.722652731167 1.0 inX1 93 | Assert <= 0.21812367541 1.0 inX2 94 | Assert >= 0.23687367541 1.0 inX2 95 | Assert <= 0.41888561998 1.0 inX3 96 | Assert >= 0.43763561998 1.0 inX3 97 | Assert <= 0.136168005711 1.0 inX4 98 | Assert >= 0.154918005711 1.0 inX4 99 | Assert <= 0.0074619598716 1.0 inX5 100 | Assert >= 0.0262119598716 1.0 inX5 101 | Assert >= 0.0 -1.0 outX0 1.0 outX1 102 | -------------------------------------------------------------------------------- /benchmarks/collisionDetection/reluBenchmark0.4976811409s_SAT.rlv: -------------------------------------------------------------------------------- 1 | Input inX0 2 | Input inX1 3 | Input inX2 4 | Input inX3 5 | Input inX4 6 | Input inX5 7 | ReLU relu1X0 -0.00770533969626 0.425551980734 inX1 -0.978725194931 inX0 0.323562651873 inX3 -0.748208045959 inX2 1.16365802288 inX5 0.462842822075 inX4 8 | ReLU relu1X1 0.163050115108 -1.73516130447 inX1 -0.403024703264 inX0 1.79504454136 inX3 -1.62804996967 inX2 -1.62756943703 inX5 1.16260421276 inX4 9 | ReLU relu1X2 0.0 -0.00936131738126 inX1 -0.000367225555237 inX0 -0.0123930452392 inX3 -0.0220121368766 inX2 0.0123939150944 inX5 0.0172470472753 inX4 10 | ReLU relu1X3 1.997371912 -0.56884264946 inX1 -1.91524398327 inX0 -2.40323376656 inX3 0.23108355701 inX2 -0.947540819645 inX5 -1.22519731522 inX4 11 | ReLU relu1X4 1.07717883587 1.1676659584 inX1 -1.24283909798 inX0 -0.396047174931 inX3 -2.16434001923 inX2 -0.408886402845 inX5 -2.67813634872 inX4 12 | ReLU relu1X5 0.17343826592 0.181639790535 inX1 -0.581120252609 inX0 -0.64011490345 inX3 0.404753178358 inX2 -0.483487933874 inX5 1.38076388836 inX4 13 | ReLU relu1X6 0.0 -0.00689489394426 inX1 -0.000427972030593 inX0 -0.0061044045724 inX3 -0.0140960309654 inX2 0.0018380060792 inX5 0.00859019160271 inX4 14 | ReLU relu1X7 -0.742009282112 -0.298721164465 inX1 1.29478132725 inX0 0.651425421238 inX3 0.0895936563611 inX2 0.0423422046006 inX5 0.148307666183 inX4 15 | ReLU relu1X8 -0.115423373878 0.685900568962 inX1 1.93089449406 inX0 -1.22263300419 inX3 -0.753214240074 inX2 0.0619786679745 inX5 -1.6351121664 inX4 16 | ReLU relu1X9 0.0 0.00137634028215 inX1 0.00524098146707 inX0 -0.0192849878222 inX3 -0.0235808435827 inX2 -0.022592831403 inX5 -0.000675619929098 inX4 17 | ReLU relu1X10 0.0 -0.0185358300805 inX1 -0.0119916889817 inX0 -0.020028449595 inX3 -0.0154279498383 inX2 -0.016379090026 inX5 0.0159496255219 inX4 18 | ReLU relu1X11 -0.78370398283 -0.0887623056769 inX1 -0.606863796711 inX0 0.967090904713 inX3 0.177570700645 inX2 -1.2135232687 inX5 2.60164833069 inX4 19 | ReLU relu1X12 0.548846662045 0.864908993244 inX1 0.0668454319239 inX0 -0.753415048122 inX3 1.34699356556 inX2 1.93251335621 inX5 -0.681420564651 inX4 20 | ReLU relu1X13 -0.0788166448474 -0.119499228895 inX1 0.150416091084 inX0 0.037571888417 inX3 0.03391116485 inX2 0.0300718322396 inX5 0.0967094302177 inX4 21 | ReLU relu1X14 -0.259192168713 1.87436282635 inX1 -0.554330527782 inX0 -1.11021459103 inX3 -0.824956774712 inX2 0.219117835164 inX5 -0.20582036674 inX4 22 | ReLU relu1X15 1.16056859493 -2.94967937469 inX1 2.14835357666 inX0 1.43194854259 inX3 -1.73117256165 inX2 0.264111965895 inX5 0.208737194538 inX4 23 | ReLU relu1X16 -0.0489889197052 0.00689587648958 inX1 -0.423297464848 inX0 0.0767475962639 inX3 0.073494695127 inX2 -0.112210214138 inX5 -0.570491492748 inX4 24 | ReLU relu1X17 -0.129528686404 -0.203352257609 inX1 1.08402097225 inX0 -0.834911823273 inX3 -0.707668423653 inX2 0.247991353273 inX5 -0.240675061941 inX4 25 | ReLU relu1X18 -1.00296258926 1.39118921757 inX1 -0.66294169426 inX0 -0.0554503202438 inX3 -0.189661204815 inX2 -1.08617722988 inX5 0.470066875219 inX4 26 | ReLU relu1X19 -0.697150945663 -0.912062466145 inX1 -0.868307471275 inX0 2.13373279572 inX3 3.01121354103 inX2 0.702499747276 inX5 0.13462087512 inX4 27 | ReLU relu1X20 0.0 -0.00638233637437 inX1 -0.0133408214897 inX0 -0.0157795976847 inX3 -0.013156812638 inX2 -0.00445888983086 inX5 0.0143963824958 inX4 28 | ReLU relu1X21 0.835042178631 -1.45171582699 inX1 3.2471768856 inX0 -1.20353543758 inX3 -0.364715337753 inX2 0.694153368473 inX5 -0.559342384338 inX4 29 | ReLU relu1X22 0.678784668446 2.04990959167 inX1 -2.52055335045 inX0 -0.892051935196 inX3 -2.30720424652 inX2 -0.711961388588 inX5 -0.314919382334 inX4 30 | ReLU relu1X23 -0.820165395737 -0.717385590076 inX1 -0.293614149094 inX0 1.96939122677 inX3 2.45270419121 inX2 0.0285975001752 inX5 0.283298283815 inX4 31 | ReLU relu1X24 -0.00352367199957 0.0112918540835 inX1 -0.0194084886461 inX0 -0.0196145884693 inX3 0.000732473796234 inX2 0.019015705213 inX5 -0.0203110277653 inX4 32 | ReLU relu1X25 -0.596717834473 0.171730518341 inX1 1.7623950243 inX0 0.257751911879 inX3 0.0750553235412 inX2 -0.800745069981 inX5 -0.279645591974 inX4 33 | ReLU relu1X26 -0.496275812387 -1.6829379797 inX1 2.78025984764 inX0 1.17823457718 inX3 2.92984175682 inX2 0.995428979397 inX5 0.53321903944 inX4 34 | ReLU relu1X27 -0.00271431682631 0.00621621869504 inX1 -0.0102649712935 inX0 -0.0073749711737 inX3 -0.00232430337928 inX2 0.0110377082601 inX5 -0.00946983881295 inX4 35 | ReLU relu1X28 -0.871306657791 1.45531868935 inX1 0.390670776367 inX0 0.309387534857 inX3 -0.471480876207 inX2 -1.02763831615 inX5 2.40831661224 inX4 36 | ReLU relu1X29 1.08917236328 0.260794758797 inX1 -0.705449640751 inX0 -2.7236187458 inX3 1.00783705711 inX2 0.248063161969 inX5 -0.65232527256 inX4 37 | ReLU relu1X30 -1.46118175983 2.39195823669 inX1 0.904803514481 inX0 -0.730318009853 inX3 0.880049049854 inX2 0.712868154049 inX5 0.913892924786 inX4 38 | ReLU relu1X31 0.0 -0.0189517997205 inX1 0.00132768705953 inX0 -0.0120694627985 inX3 -0.0165205504745 inX2 -0.0090703247115 inX5 -0.0113717345521 inX4 39 | ReLU relu1X32 -1.34767282009 -1.05237591267 inX1 1.8539005518 inX0 1.34944605827 inX3 5.46926450729 inX2 0.708325862885 inX5 -0.0294558051974 inX4 40 | ReLU relu1X33 -0.434490591288 -0.277234792709 inX1 0.223877891898 inX0 0.397379428148 inX3 -0.404961168766 inX2 -0.406214952469 inX5 0.349417716265 inX4 41 | ReLU relu1X34 -2.15188145638 4.04485225677 inX1 -0.431448847055 inX0 -0.446634471416 inX3 1.0480017662 inX2 -0.00445634359494 inX5 -0.0966049358249 inX4 42 | ReLU relu1X35 -0.00407106988132 -0.0185089353472 inX1 0.00325125502422 inX0 -0.00835816655308 inX3 -0.00515520060435 inX2 0.0178822875023 inX5 -0.0205950625241 inX4 43 | ReLU relu1X36 -0.0119612775743 -0.00393535755575 inX1 0.00174772075843 inX0 0.00727396132424 inX3 -0.0230750106275 inX2 -0.00189159135334 inX5 0.0259838290513 inX4 44 | ReLU relu1X37 -0.731101572514 -0.521424710751 inX1 2.24679780006 inX0 1.03144669533 inX3 -2.47750687599 inX2 0.531722068787 inX5 -0.830998361111 inX4 45 | ReLU relu1X38 -0.172267585993 -1.25004553795 inX1 0.32142239809 inX0 0.631538450718 inX3 2.67303180695 inX2 -1.4778059721 inX5 -0.0117573086172 inX4 46 | ReLU relu1X39 0.70444136858 -2.11956572533 inX1 0.341825067997 inX0 0.279247134924 inX3 0.359533041716 inX2 2.32777523994 inX5 0.0277868025005 inX4 47 | MaxPool pool1X0X0X0 relu1X0 relu1X1 relu1X2 relu1X3 48 | MaxPool pool1X0X0X1 relu1X2 relu1X3 relu1X4 relu1X5 49 | MaxPool pool1X0X0X2 relu1X4 relu1X5 relu1X6 relu1X7 50 | MaxPool pool1X0X0X3 relu1X6 relu1X7 relu1X8 relu1X9 51 | MaxPool pool1X0X0X4 relu1X8 relu1X9 relu1X10 relu1X11 52 | MaxPool pool1X0X0X5 relu1X10 relu1X11 relu1X12 relu1X13 53 | MaxPool pool1X0X0X6 relu1X12 relu1X13 relu1X14 relu1X15 54 | MaxPool pool1X0X0X7 relu1X14 relu1X15 relu1X16 relu1X17 55 | MaxPool pool1X0X0X8 relu1X16 relu1X17 relu1X18 relu1X19 56 | MaxPool pool1X0X0X9 relu1X18 relu1X19 relu1X20 relu1X21 57 | MaxPool pool1X0X0X10 relu1X20 relu1X21 relu1X22 relu1X23 58 | MaxPool pool1X0X0X11 relu1X22 relu1X23 relu1X24 relu1X25 59 | MaxPool pool1X0X0X12 relu1X24 relu1X25 relu1X26 relu1X27 60 | MaxPool pool1X0X0X13 relu1X26 relu1X27 relu1X28 relu1X29 61 | MaxPool pool1X0X0X14 relu1X28 relu1X29 relu1X30 relu1X31 62 | MaxPool pool1X0X0X15 relu1X30 relu1X31 relu1X32 relu1X33 63 | MaxPool pool1X0X0X16 relu1X32 relu1X33 relu1X34 relu1X35 64 | MaxPool pool1X0X0X17 relu1X34 relu1X35 relu1X36 relu1X37 65 | MaxPool pool1X0X0X18 relu1X36 relu1X37 relu1X38 relu1X39 66 | ReLU relu2X0 -0.00211276905611 -0.0167680978775 pool1X0X0X16 -0.0100319618359 pool1X0X0X17 -0.00543770845979 pool1X0X0X14 -0.0136471735314 pool1X0X0X15 0.00544194458053 pool1X0X0X12 0.00283113261685 pool1X0X0X13 -0.00646980339661 pool1X0X0X10 -0.0149113032967 pool1X0X0X11 0.000277536804788 pool1X0X0X18 -0.00547050312161 pool1X0X0X4 0.00965722277761 pool1X0X0X5 -0.00314164487645 pool1X0X0X6 0.00262131495401 pool1X0X0X7 -0.0139371883124 pool1X0X0X0 -0.0117555465549 pool1X0X0X1 0.0118925459683 pool1X0X0X2 -0.0023211245425 pool1X0X0X3 -0.00413575721905 pool1X0X0X8 -0.00542060192674 pool1X0X0X9 67 | ReLU relu2X1 0.930051267147 -0.35909435153 pool1X0X0X16 0.599014222622 pool1X0X0X17 -0.146365523338 pool1X0X0X14 -0.561448276043 pool1X0X0X15 0.719234764576 pool1X0X0X12 -0.388034075499 pool1X0X0X13 -0.558998644352 pool1X0X0X10 -0.477382898331 pool1X0X0X11 0.586802005768 pool1X0X0X18 0.240489766002 pool1X0X0X4 -0.987980782986 pool1X0X0X5 0.880404531956 pool1X0X0X6 -1.49782693386 pool1X0X0X7 -0.0588516965508 pool1X0X0X0 -0.571606338024 pool1X0X0X1 1.65079474449 pool1X0X0X2 -0.0989808738232 pool1X0X0X3 0.120151117444 pool1X0X0X8 1.11836397648 pool1X0X0X9 68 | ReLU relu2X2 0.48064750433 -0.689829826355 pool1X0X0X16 -0.0137706082314 pool1X0X0X17 -0.39030367136 pool1X0X0X14 0.00849942304194 pool1X0X0X15 0.894917368889 pool1X0X0X12 0.246981665492 pool1X0X0X13 -0.699603497982 pool1X0X0X10 -1.71710574627 pool1X0X0X11 -0.673752188683 pool1X0X0X18 0.176278740168 pool1X0X0X4 0.140991672873 pool1X0X0X5 0.618384122849 pool1X0X0X6 -0.179051890969 pool1X0X0X7 -0.442848592997 pool1X0X0X0 0.0496455356479 pool1X0X0X1 1.33427834511 pool1X0X0X2 -0.0341505073011 pool1X0X0X3 -1.03307497501 pool1X0X0X8 0.0355235487223 pool1X0X0X9 69 | ReLU relu2X3 -0.68002229929 0.673226952553 pool1X0X0X16 1.61801981926 pool1X0X0X17 0.667186141014 pool1X0X0X14 -0.345945626497 pool1X0X0X15 -1.46472978592 pool1X0X0X12 -0.913834571838 pool1X0X0X13 -0.171317994595 pool1X0X0X10 -0.151650026441 pool1X0X0X11 -0.760961890221 pool1X0X0X18 -0.135002657771 pool1X0X0X4 0.751482665539 pool1X0X0X5 0.952252745628 pool1X0X0X6 0.932196617126 pool1X0X0X7 1.78008031845 pool1X0X0X0 0.0751789659262 pool1X0X0X1 -0.353252470493 pool1X0X0X2 -0.0905419066548 pool1X0X0X3 -1.70057868958 pool1X0X0X8 -1.54268991947 pool1X0X0X9 70 | ReLU relu2X4 -0.000993702560663 -0.0102032152936 pool1X0X0X16 -0.000864396104589 pool1X0X0X17 0.00602678349242 pool1X0X0X14 -0.0120005309582 pool1X0X0X15 -0.0115594500676 pool1X0X0X12 -0.012119339779 pool1X0X0X13 0.0045363008976 pool1X0X0X10 -8.18230910227e-06 pool1X0X0X11 -0.00286158663221 pool1X0X0X18 -0.00612418260425 pool1X0X0X4 0.00898835249245 pool1X0X0X5 -0.00315074482933 pool1X0X0X6 -0.0104464432225 pool1X0X0X7 0.00151618360542 pool1X0X0X0 -0.00115575431846 pool1X0X0X1 -0.00717756245285 pool1X0X0X2 0.000666244945023 pool1X0X0X3 -0.00564216868952 pool1X0X0X8 0.00614798162133 pool1X0X0X9 71 | ReLU relu2X5 -0.332929223776 2.37426233292 pool1X0X0X16 -2.03670310974 pool1X0X0X17 -2.8912191391 pool1X0X0X14 1.52849149704 pool1X0X0X15 1.17873549461 pool1X0X0X12 1.37006962299 pool1X0X0X13 0.179084584117 pool1X0X0X10 -1.1598931551 pool1X0X0X11 2.76042580605 pool1X0X0X18 1.91608083248 pool1X0X0X4 1.67609345913 pool1X0X0X5 -2.62268400192 pool1X0X0X6 0.928763329983 pool1X0X0X7 -2.13156437874 pool1X0X0X0 0.513960957527 pool1X0X0X1 -2.15346550941 pool1X0X0X2 1.0520927906 pool1X0X0X3 1.86331820488 pool1X0X0X8 0.697883486748 pool1X0X0X9 72 | ReLU relu2X6 2.35051655769 -1.16184175014 pool1X0X0X16 -0.0613299719989 pool1X0X0X17 0.421689093113 pool1X0X0X14 -0.263244539499 pool1X0X0X15 0.344555318356 pool1X0X0X12 0.0316255427897 pool1X0X0X13 -2.50629043579 pool1X0X0X10 -1.70668935776 pool1X0X0X11 -0.249095007777 pool1X0X0X18 0.289316236973 pool1X0X0X4 1.30095112324 pool1X0X0X5 0.856586158276 pool1X0X0X6 -1.708091259 pool1X0X0X7 0.672471165657 pool1X0X0X0 0.460894107819 pool1X0X0X1 -0.248897403479 pool1X0X0X2 0.22223508358 pool1X0X0X3 0.281160831451 pool1X0X0X8 0.344686955214 pool1X0X0X9 73 | ReLU relu2X7 -0.747793495655 0.398894876242 pool1X0X0X16 1.37313473225 pool1X0X0X17 0.278879523277 pool1X0X0X14 -0.149582326412 pool1X0X0X15 -0.31207498908 pool1X0X0X12 0.0704577416182 pool1X0X0X13 -0.151936247945 pool1X0X0X10 -0.324735641479 pool1X0X0X11 0.237951368093 pool1X0X0X18 0.369472593069 pool1X0X0X4 -1.27846956253 pool1X0X0X5 0.889570593834 pool1X0X0X6 -0.316260635853 pool1X0X0X7 0.71803855896 pool1X0X0X0 -1.0855525732 pool1X0X0X1 0.654287040234 pool1X0X0X2 -0.344522356987 pool1X0X0X3 0.822935521603 pool1X0X0X8 1.31374585629 pool1X0X0X9 74 | ReLU relu2X8 -0.986371278763 -0.178143337369 pool1X0X0X16 1.37320578098 pool1X0X0X17 0.918277025223 pool1X0X0X14 -0.53895008564 pool1X0X0X15 -1.65199685097 pool1X0X0X12 -0.598373055458 pool1X0X0X13 -0.291583478451 pool1X0X0X10 0.444794863462 pool1X0X0X11 -1.24869203568 pool1X0X0X18 -0.732813775539 pool1X0X0X4 0.261008918285 pool1X0X0X5 1.80278527737 pool1X0X0X6 -0.134303182364 pool1X0X0X7 1.85704684258 pool1X0X0X0 0.623540520668 pool1X0X0X1 0.455230981112 pool1X0X0X2 -0.552643656731 pool1X0X0X3 -0.611319899559 pool1X0X0X8 -2.74322128296 pool1X0X0X9 75 | ReLU relu2X9 -6.36781915091e-05 0.000304907065583 pool1X0X0X16 -0.000854436715599 pool1X0X0X17 -0.00520235998556 pool1X0X0X14 -0.011434758082 pool1X0X0X15 -0.0129004782066 pool1X0X0X12 0.00349430507049 pool1X0X0X13 -0.00165601004846 pool1X0X0X10 -0.0113796694204 pool1X0X0X11 -0.0114006707445 pool1X0X0X18 0.0103476662189 pool1X0X0X4 0.00565689476207 pool1X0X0X5 -0.0108053041622 pool1X0X0X6 0.0072118951939 pool1X0X0X7 -0.00952114257962 pool1X0X0X0 -0.00449769059196 pool1X0X0X1 0.00849624536932 pool1X0X0X2 -0.00346445781179 pool1X0X0X3 0.00448209512979 pool1X0X0X8 -0.00106061587576 pool1X0X0X9 76 | ReLU relu2X10 0.255233615637 -0.381480574608 pool1X0X0X16 0.0285897199064 pool1X0X0X17 0.328787475824 pool1X0X0X14 -0.36847832799 pool1X0X0X15 -0.641218245029 pool1X0X0X12 -0.478239655495 pool1X0X0X13 -0.0069968146272 pool1X0X0X10 -0.0227739345282 pool1X0X0X11 -0.682260632515 pool1X0X0X18 -0.141913816333 pool1X0X0X4 -0.478864818811 pool1X0X0X5 -0.264536470175 pool1X0X0X6 0.596308290958 pool1X0X0X7 0.346717894077 pool1X0X0X0 0.126566499472 pool1X0X0X1 0.188611090183 pool1X0X0X2 -0.126221060753 pool1X0X0X3 0.0124475061893 pool1X0X0X8 -0.04133348912 pool1X0X0X9 77 | ReLU relu2X11 -0.355603575706 0.402410417795 pool1X0X0X16 0.592986106873 pool1X0X0X17 -0.201115906239 pool1X0X0X14 -0.190337076783 pool1X0X0X15 -0.510640621185 pool1X0X0X12 -0.0390233099461 pool1X0X0X13 0.749961316586 pool1X0X0X10 0.0191912688315 pool1X0X0X11 -0.310647159815 pool1X0X0X18 0.17132781446 pool1X0X0X4 -0.966048777103 pool1X0X0X5 0.336175918579 pool1X0X0X6 -0.19271287322 pool1X0X0X7 0.340436637402 pool1X0X0X0 -0.749889731407 pool1X0X0X1 0.540169596672 pool1X0X0X2 -0.568409442902 pool1X0X0X3 0.35270050168 pool1X0X0X8 0.815179109573 pool1X0X0X9 78 | ReLU relu2X12 0.0 -0.00832767225802 pool1X0X0X16 -0.00366391893476 pool1X0X0X17 0.0130585469306 pool1X0X0X14 -0.00603838358074 pool1X0X0X15 -0.00424641137943 pool1X0X0X12 -0.00824540108442 pool1X0X0X13 -0.0068019493483 pool1X0X0X10 -0.000334977026796 pool1X0X0X11 0.0072642378509 pool1X0X0X18 -0.00990438647568 pool1X0X0X4 0.00342006213032 pool1X0X0X5 -0.0125209083781 pool1X0X0X6 -0.00143784796819 pool1X0X0X7 -0.00225481181405 pool1X0X0X0 -0.00849202182144 pool1X0X0X1 -0.000823586713523 pool1X0X0X2 -0.00175395270344 pool1X0X0X3 -0.00317804492079 pool1X0X0X8 0.00587154971436 pool1X0X0X9 79 | ReLU relu2X13 0.0 -0.011082935147 pool1X0X0X16 -0.00977044925094 pool1X0X0X17 -0.00129137269687 pool1X0X0X14 0.00831097923219 pool1X0X0X15 -0.00879818759859 pool1X0X0X12 -0.00972574576735 pool1X0X0X13 -0.0062761050649 pool1X0X0X10 -0.00175052578561 pool1X0X0X11 0.0122373513877 pool1X0X0X18 -0.00342879327945 pool1X0X0X4 0.00337444711477 pool1X0X0X5 -0.0115696303546 pool1X0X0X6 -0.0114610707387 pool1X0X0X7 -0.00860353931785 pool1X0X0X0 -0.00688825780526 pool1X0X0X1 -0.013207770884 pool1X0X0X2 -0.00555723626167 pool1X0X0X3 -0.00504626985639 pool1X0X0X8 0.00148337567225 pool1X0X0X9 80 | ReLU relu2X14 -0.00300744315609 0.00371964811347 pool1X0X0X16 -0.00748305348679 pool1X0X0X17 0.00325666740537 pool1X0X0X14 -0.00818553008139 pool1X0X0X15 -0.00375646818429 pool1X0X0X12 -0.0123562868685 pool1X0X0X13 0.00314318318851 pool1X0X0X10 -0.00190438842401 pool1X0X0X11 -0.00467666005716 pool1X0X0X18 -0.0106420889497 pool1X0X0X4 -0.0136025790125 pool1X0X0X5 0.00922034680843 pool1X0X0X6 -0.00130823371001 pool1X0X0X7 8.90502851689e-05 pool1X0X0X0 0.006133351475 pool1X0X0X1 -0.00542199192569 pool1X0X0X2 -0.0107323583215 pool1X0X0X3 -0.00951135437936 pool1X0X0X8 -0.00227686366998 pool1X0X0X9 81 | ReLU relu2X15 -0.176535978913 -0.0176770277321 pool1X0X0X16 -0.130379706621 pool1X0X0X17 -0.410345822573 pool1X0X0X14 -0.0433257557452 pool1X0X0X15 -0.312845230103 pool1X0X0X12 -0.70596832037 pool1X0X0X13 0.199828967452 pool1X0X0X10 0.926399946213 pool1X0X0X11 -0.398421525955 pool1X0X0X18 -0.290224283934 pool1X0X0X4 -0.179846212268 pool1X0X0X5 -0.235930994153 pool1X0X0X6 -0.471221894026 pool1X0X0X7 0.809457957745 pool1X0X0X0 1.0689958334 pool1X0X0X1 0.438100516796 pool1X0X0X2 -0.0459677278996 pool1X0X0X3 0.156665533781 pool1X0X0X8 -0.400512248278 pool1X0X0X9 82 | ReLU relu2X16 -0.139173194766 0.526388525963 pool1X0X0X16 0.416673064232 pool1X0X0X17 -0.0640570670366 pool1X0X0X14 0.368198245764 pool1X0X0X15 -0.131311908364 pool1X0X0X12 -0.279185414314 pool1X0X0X13 -0.229648903012 pool1X0X0X10 0.0516070090234 pool1X0X0X11 -0.237098366022 pool1X0X0X18 -0.369061380625 pool1X0X0X4 -0.11653419584 pool1X0X0X5 -0.233986124396 pool1X0X0X6 0.0886740460992 pool1X0X0X7 0.434254616499 pool1X0X0X0 0.341647446156 pool1X0X0X1 -0.0467130988836 pool1X0X0X2 0.0303373988718 pool1X0X0X3 0.283620357513 pool1X0X0X8 -0.349927395582 pool1X0X0X9 83 | ReLU relu2X17 -0.0148857617751 0.0287718307227 pool1X0X0X16 -0.0923720374703 pool1X0X0X17 0.0421522185206 pool1X0X0X14 0.073689378798 pool1X0X0X15 0.0291165020317 pool1X0X0X12 0.0904093533754 pool1X0X0X13 -0.034650593996 pool1X0X0X10 -0.091021925211 pool1X0X0X11 0.0259976200759 pool1X0X0X18 -0.0151482895017 pool1X0X0X4 0.146342054009 pool1X0X0X5 -0.0273102000356 pool1X0X0X6 -0.00108325609472 pool1X0X0X7 0.0488103441894 pool1X0X0X0 -0.0181279387325 pool1X0X0X1 -0.0719872117043 pool1X0X0X2 -0.0166891142726 pool1X0X0X3 -0.00461307773367 pool1X0X0X8 -0.0254984740168 pool1X0X0X9 84 | ReLU relu2X18 -0.47851973772 -1.2299683094 pool1X0X0X16 -0.838822722435 pool1X0X0X17 -0.316068828106 pool1X0X0X14 -0.539191305637 pool1X0X0X15 -0.501975655556 pool1X0X0X12 0.252721905708 pool1X0X0X13 1.36553764343 pool1X0X0X10 1.04609847069 pool1X0X0X11 -1.17921805382 pool1X0X0X18 -0.243340715766 pool1X0X0X4 1.46329593658 pool1X0X0X5 0.318324506283 pool1X0X0X6 0.693471610546 pool1X0X0X7 -0.99070250988 pool1X0X0X0 0.664568066597 pool1X0X0X1 -0.706344544888 pool1X0X0X2 0.244342118502 pool1X0X0X3 0.181315600872 pool1X0X0X8 0.177134156227 pool1X0X0X9 85 | Linear ip2X0 -0.105323210359 -0.00796643085778 relu2X0 -2.00408577919 relu2X1 -1.95536220074 relu2X2 2.97320175171 relu2X3 -0.0097716813907 relu2X4 4.58163309097 relu2X5 -3.20851206779 relu2X6 -1.99810171127 relu2X7 3.46907758713 relu2X8 0.00670911418274 relu2X9 1.09451031685 relu2X10 -1.42950892448 relu2X11 -0.00646871747449 relu2X12 0.00956485699862 relu2X13 -0.00773688452318 relu2X14 1.44270324707 relu2X15 0.833081662655 relu2X16 0.161857798696 relu2X17 2.23075556755 relu2X18 86 | Linear ip2X1 0.105313919485 0.0229359231889 relu2X0 2.00725245476 relu2X1 1.94528210163 relu2X2 -2.97571539879 relu2X3 0.00466247182339 relu2X4 -4.58863401413 relu2X5 3.20820689201 relu2X6 1.9868901968 relu2X7 -3.48216128349 relu2X8 -0.0112616531551 relu2X9 -1.08817493916 relu2X10 1.43029725552 relu2X11 -0.00300858076662 relu2X12 -0.0119460858405 relu2X13 0.000313411379466 relu2X14 -1.41833353043 relu2X15 -0.843563973904 relu2X16 -0.177298650146 relu2X17 -2.2320356369 relu2X18 87 | Linear outX0 0.0 1.0 ip2X0 88 | Linear outX1 0.0 1.0 ip2X1 89 | Assert <= 0.695097821487 1.0 inX0 90 | Assert >= 0.757597821487 1.0 inX0 91 | Assert <= 0.414769809567 1.0 inX1 92 | Assert >= 0.477269809567 1.0 inX1 93 | Assert <= 0.153059967992 1.0 inX2 94 | Assert >= 0.215559967992 1.0 inX2 95 | Assert <= 0.48611691512 1.0 inX3 96 | Assert >= 0.54861691512 1.0 inX3 97 | Assert <= 0.26590834305 1.0 inX4 98 | Assert >= 0.32840834305 1.0 inX4 99 | Assert <= -0.323779260077 1.0 inX5 100 | Assert >= -0.261279260077 1.0 inX5 101 | Assert >= 0.0 -1.0 outX1 1.0 outX0 102 | --------------------------------------------------------------------------------