├── sat ├── minisat220 │ ├── LINK │ ├── LIBS │ ├── ipasir.h │ ├── .gitignore │ ├── minisat-220.tar.gz │ ├── minisat-config.patch │ ├── README │ ├── minisat-cc.patch │ ├── minisat-h.patch │ ├── makefile │ └── ipasirminisatglue.cc ├── picosat961 │ ├── ipasir.h │ ├── .gitignore │ ├── picosat-961.tar.gz │ ├── ipasirpicosatglue.c │ └── makefile ├── lingelingbcj │ ├── ipasir.h │ ├── ipasirlingelingglue.cpp │ └── makefile └── README ├── app ├── icnf │ ├── ipasir.h │ ├── README │ └── makefile ├── genipabones │ ├── ipasir.h │ ├── makefile │ └── genipabones.cpp ├── genipafolio │ ├── ipasir.h │ ├── .gitignore │ ├── README │ ├── Threading.h │ ├── makefile │ └── genipafolio.cpp ├── genipalsp │ ├── ipasir.h │ ├── README │ ├── inputs │ │ ├── maze-10-0.5-8.grid │ │ ├── maze-12-0.3-1.grid │ │ └── maze-13-0.3-1.grid │ └── makefile ├── genipamax │ ├── ipasir.h │ ├── .gitignore │ ├── pblib.tar.gz │ ├── README │ ├── buildPblib.sh │ ├── makefile │ └── genipamax.cpp ├── genipareach │ ├── ipasir.h │ ├── makefile │ └── genipareach.cpp ├── genipasat │ ├── ipasir.h │ ├── .gitignore │ ├── README │ ├── makefile │ └── genipasat.c ├── genipaessentials │ ├── ipasir.h │ ├── README │ ├── makefile │ └── genipaessentials.cpp ├── ipasir-check-conflict │ ├── ipasir.h │ ├── .gitignore │ ├── inputs │ │ └── examples.txt │ ├── README │ ├── ipasir-check-conflict.cc │ ├── makefile │ └── SATSolver.h ├── ipasir-check-satunsat │ ├── ipasir.h │ ├── .gitignore │ ├── inputs │ │ └── examples.txt │ ├── README │ ├── makefile │ └── SATSolver.h ├── ipasir-check-iterative │ ├── ipasir.h │ ├── .gitignore │ ├── inputs │ │ └── examples.txt │ ├── README │ ├── makefile │ ├── ipasir-check-iterative.cc │ └── SATSolver.h ├── incplan │ ├── src │ │ └── incplan │ │ │ ├── bin │ │ │ └── .gitignore │ │ │ ├── build │ │ │ └── .gitignore │ │ │ ├── lib │ │ │ └── .gitignore │ │ │ ├── src │ │ │ ├── misc.h │ │ │ ├── main.cpp │ │ │ ├── TimeSlotMapping.cpp │ │ │ ├── carj │ │ │ │ ├── logging.h │ │ │ │ ├── ScopedTimer.h │ │ │ │ ├── carj.cpp │ │ │ │ └── carj.h │ │ │ ├── CMake │ │ │ │ ├── gtest-download.cmake │ │ │ │ └── gtest.cmake │ │ │ ├── libs │ │ │ │ ├── ipasir │ │ │ │ │ ├── test │ │ │ │ │ │ └── mock_ipasir_cpp.h │ │ │ │ │ ├── ipasir_cpp.cpp │ │ │ │ │ └── randomized_ipasir.h │ │ │ │ └── tclap │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── LICENSE.txt │ │ │ │ │ ├── Visitor.h │ │ │ │ │ ├── IgnoreRestVisitor.h │ │ │ │ │ ├── OptionalUnlabeledTracker.h │ │ │ │ │ ├── Constraint.h │ │ │ │ │ ├── CmdLineOutput.h │ │ │ │ │ ├── HelpVisitor.h │ │ │ │ │ ├── VersionVisitor.h │ │ │ │ │ ├── ArgTraits.h │ │ │ │ │ ├── ValuesConstraint.h │ │ │ │ │ ├── CmdLineInterface.h │ │ │ │ │ └── XorHandler.h │ │ │ ├── ipasirprint.cpp │ │ │ ├── unit_tests │ │ │ │ ├── TestTimePointBasedSolver.cpp │ │ │ │ └── TestTimeSlotMapping.cpp │ │ │ ├── TimePointBasedSolver.h │ │ │ └── CMakeLists.txt │ │ │ ├── testdata │ │ │ └── mini1.cnf │ │ │ ├── experiment │ │ │ ├── collectData │ │ │ ├── hardware_model_checking │ │ │ │ ├── runAll │ │ │ │ └── runSingle │ │ │ ├── runSrt │ │ │ ├── runSingleMadagascar │ │ │ ├── icaps17 │ │ │ │ └── README │ │ │ ├── runMadagascar │ │ │ └── runSingleIncrementalExperiment │ │ │ ├── LICENSE.md │ │ │ └── README.md │ ├── makefile │ └── README └── README ├── bin └── .gitignore ├── .gitmodules ├── makefile ├── scripts ├── mkcln.sh ├── mkall.sh └── mkone.sh ├── .gitignore ├── README.md └── LICENSE /sat/minisat220/LINK: -------------------------------------------------------------------------------- 1 | g++ 2 | -------------------------------------------------------------------------------- /app/icnf/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /sat/minisat220/LIBS: -------------------------------------------------------------------------------- 1 | -lm -lz 2 | -------------------------------------------------------------------------------- /app/genipabones/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipafolio/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipalsp/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipamax/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipareach/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipasat/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | genipa* 2 | *.jar 3 | -------------------------------------------------------------------------------- /sat/minisat220/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /sat/picosat961/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipaessentials/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /sat/lingelingbcj/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipasat/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipasat 3 | -------------------------------------------------------------------------------- /app/ipasir-check-conflict/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/ipasir-check-satunsat/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /app/genipafolio/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipafolio 3 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/ipasir.h: -------------------------------------------------------------------------------- 1 | ../../ipasir.h -------------------------------------------------------------------------------- /sat/picosat961/.gitignore: -------------------------------------------------------------------------------- 1 | .o 2 | .a 3 | picosat-* 4 | -------------------------------------------------------------------------------- /app/genipamax/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipamax 3 | pblib 4 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /app/incplan/src/incplan/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /app/incplan/src/incplan/lib/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /app/ipasir-check-conflict/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipasat 3 | -------------------------------------------------------------------------------- /app/ipasir-check-satunsat/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipasat 3 | -------------------------------------------------------------------------------- /sat/minisat220/.gitignore: -------------------------------------------------------------------------------- 1 | .*o 2 | .*a 3 | minisat-* 4 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | genipasat 3 | -------------------------------------------------------------------------------- /app/README: -------------------------------------------------------------------------------- 1 | Plugabble apps for IPASIR. 2 | Currently all work with 'combine.sh'. 3 | -------------------------------------------------------------------------------- /app/genipamax/pblib.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biotomas/ipasir/HEAD/app/genipamax/pblib.tar.gz -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sat/lawa"] 2 | path = sat/lawa 3 | url = https://github.com/biotomas/lawa.git 4 | -------------------------------------------------------------------------------- /sat/minisat220/minisat-220.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biotomas/ipasir/HEAD/sat/minisat220/minisat-220.tar.gz -------------------------------------------------------------------------------- /sat/picosat961/picosat-961.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biotomas/ipasir/HEAD/sat/picosat961/picosat-961.tar.gz -------------------------------------------------------------------------------- /app/ipasir-check-conflict/inputs/examples.txt: -------------------------------------------------------------------------------- 1 | 1 1 2 | 2 2 3 | 2 1 4 | 1 2 5 | 10000 10002 6 | 10002 10000 7 | 9999 10002 8 | 10002 9999 9 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/misc.h: -------------------------------------------------------------------------------- 1 | namespace incplan { 2 | template 3 | inline void UNUSED( T const & result ) { static_cast(result); } 4 | } 5 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/main.cpp: -------------------------------------------------------------------------------- 1 | int incplan_main(int argc, const char **argv); 2 | 3 | int main(int argc, const char **argv) { 4 | return incplan_main(argc, argv); 5 | } -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "makefile: use 'make verbose' for verbose output" 3 | @scripts/mkall.sh|grep 'mkone' 4 | verbose: 5 | scripts/mkall.sh 6 | clean: 7 | scripts/mkcln.sh 8 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/TimeSlotMapping.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeSlotMapping.h" 2 | 3 | const int DoubleEndedTimePointManager::FROM_BEGIN = 0; 4 | const int DoubleEndedTimePointManager::FROM_END = 1; -------------------------------------------------------------------------------- /app/genipalsp/README: -------------------------------------------------------------------------------- 1 | The application finds the longest (highest number of vertices) 2 | simple path (a path without repeated vertices) in a graph. 3 | 4 | Tomas Balyo 5 | KIT, Karlsruhe 6 | 4.5.2017 7 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/testdata/mini1.cnf: -------------------------------------------------------------------------------- 1 | c number of states: 2 2 | c number of action vars: 0 3 | i cnf 2 2 4 | 1 0 5 | -2 0 6 | u cnf 2 0 7 | g cnf 2 1 8 | 2 0 9 | t cnf 4 2 10 | -1 4 0 11 | 1 -4 0 12 | -------------------------------------------------------------------------------- /app/icnf/README: -------------------------------------------------------------------------------- 1 | Very simple stand-alone SAT solver which in essence is just a parser. 2 | 3 | You might want to read the comments in 'makefile' carefully if you want 4 | to adapt this applications to your own needs. 5 | -------------------------------------------------------------------------------- /app/genipasat/README: -------------------------------------------------------------------------------- 1 | Very simple stand-alone SAT solver which in essence is just a parser. 2 | 3 | You might want to read the comments in 'makefile' carefully if you want 4 | to adapt this applications to your own needs. 5 | -------------------------------------------------------------------------------- /app/incplan/makefile: -------------------------------------------------------------------------------- 1 | IPASIRSOLVER ?= picosat961 2 | 3 | all: 4 | cd src/incplan/build; \ 5 | cmake ../src -DBUILD_TESTS=OFF -DIPASIR_DIR="../../../../../sat/${IPASIRSOLVER}"; \ 6 | make 7 | cp src/incplan/bin/incplan-${IPASIRSOLVER} ./incplan 8 | -------------------------------------------------------------------------------- /scripts/mkcln.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | for make in app/*/makefile sat/*/makefile 3 | do 4 | make -C `dirname $make` clean 5 | done 6 | echo "mkcln.sh: Entering directory '`pwd`/bin'" 7 | cd bin/ || exit 1 8 | echo "rm -f \`cat .gitignore\`" 9 | rm -f `cat .gitignore` 10 | -------------------------------------------------------------------------------- /app/ipasir-check-conflict/README: -------------------------------------------------------------------------------- 1 | A binary that tests the implementation of the learnt clause sharing 2 | of the ipasir interface. The binary takes 2 numbers as input, the maximum size 3 | of a clause to be shared, and a size of a conflict that might be triggered in 4 | the solver. 5 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/inputs/examples.txt: -------------------------------------------------------------------------------- 1 | ./ipasir-check-iterative 100000 5 5000 # should be around 6 minutes 2 | ./ipasir-check-iterative 200000 5 5000 # should be around 12 minutes 3 | ./ipasir-check-iterative 300 3 300000 # should be around 1 minutes 4 | ./ipasir-check-iterative 2000 5 30000 # should be around 1 minutes 5 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/collectData: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -name result -exec echo {} \; -exec grep -E "(Time)|(Plan is)|(OutOfMemoryException)|(runSingleIncrementalExperiment)|(^ci)" '{}' /dev/null \; > collectedData.txt 3 | find . -name result -exec bash -c "grep -o -E '(^[0-9]*:)|(^STEP [0-9]*)' -H '{}' | tail -n1" \; >> collectedData.txt -------------------------------------------------------------------------------- /sat/minisat220/minisat-config.patch: -------------------------------------------------------------------------------- 1 | --- config.mk 2021-10-11 13:30:59.278668300 +0200 2 | +++ config2.mk 2021-10-11 13:31:31.748668300 +0200 3 | @@ -1,6 +1,6 @@ 4 | BUILD_DIR?=build 5 | MINISAT_RELSYM?=-g 6 | -MINISAT_REL?=-O3 -D NDEBUG 7 | +MINISAT_REL?=-O3 -D NDEBUG -fPIC 8 | MINISAT_DEB?=-O0 -D DEBUG 9 | MINISAT_PRF?=-O3 -D NDEBUG 10 | MINISAT_FPIC?=-fpic 11 | -------------------------------------------------------------------------------- /app/genipamax/README: -------------------------------------------------------------------------------- 1 | Genipamax is a trivial partial Max-SAT solver 2 | based on adding activation literals to soft clauses 3 | and encoding a cardinality constraint on these activation literals. 4 | To encode the cardinality constraint pblib[1] is used. 5 | 6 | [1] http://tools.computational-logic.org/content/pblib.php 7 | 8 | Tomas Balyo 9 | KIT, Karlsruhe 10 | 22.1.2015 11 | -------------------------------------------------------------------------------- /app/genipafolio/README: -------------------------------------------------------------------------------- 1 | A trivial porfolio SAT solver based on the ipasir interface. 2 | Starts a given number (second parameter, default 4) of threads 3 | each running the linked SAT solver on the same input (first parameter). 4 | The clauses of the formula are shuffled for each thread in order 5 | to diversify the portfolio. 6 | 7 | Tomas Balyo 8 | KIT, Karlsruhe 9 | 22.1.2015 10 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/hardware_model_checking/runAll: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | 4 | zipFile="$1" 5 | unzip -Z1 $zipFile | grep ".srt" > problemList.txt 6 | 7 | ~/bin/parallel -j 16 --rpl '{..} 1 $_=$job->slot()-1' taskset -c {..} {} ::: $DIR/runSingle ::: $zipFile :::: problemList.txt ::: cominisatps2sun_nopre ::: '-r 0.5' '-s' '-n' -------------------------------------------------------------------------------- /app/ipasir-check-satunsat/inputs/examples.txt: -------------------------------------------------------------------------------- 1 | ./ipasir-check-satunsat 100000 5 5000 # should be around 6 minutes 2 | ./ipasir-check-satunsat 200000 5 5000 # should be around 12 minutes 3 | ./ipasir-check-satunsat 300 3 300000 # should be around 1 minutes 4 | ./ipasir-check-satunsat 2000 5 30000 # should be around 1 minutes 5 | ./ipasir-check-satunsat 200000 2 30 # pretty short, but more SAT calls 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/carj/logging.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Usage: 3 | * Log(Level) << "message"; 4 | * LOG(LEVEL) << "message"; 5 | * TIMED_FUNC(obj-name) 6 | * TIMED_SCOPE(obj-name, block-name) 7 | */ 8 | 9 | //#define ELPP_DISABLE_PERFORMANCE_TRACKING 10 | //#define ELPP_DISABLE_VERBOSE_LOGS 11 | //#define ELPP_DISABLE_INFO_LOGS 12 | #define ELPP_FRESH_LOG_FILE 13 | #define ELPP_NO_DEFAULT_LOG_FILE 14 | #define ELPP_DISABLE_DEFAULT_CRASH_HANDLING 15 | #include "easylogging++.h" -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/CMake/gtest-download.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | 3 | project(googletest-download NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(googletest 7 | GIT_REPOSITORY https://github.com/google/googletest.git 8 | GIT_TAG master 9 | SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" 10 | BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" 11 | CONFIGURE_COMMAND "" 12 | BUILD_COMMAND "" 13 | INSTALL_COMMAND "" 14 | TEST_COMMAND "" 15 | UPDATE_COMMAND "" 16 | ) 17 | -------------------------------------------------------------------------------- /scripts/mkall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | die () { 3 | echo "*** mkall.sh: $*" 1>&2 4 | exit 1 5 | } 6 | msg () { 7 | echo "$*" 8 | } 9 | apps="`ls app/*/makefile|sed -e 's,app/,,' -e 's,/makefile,,'`" 10 | sats="`ls sat/*/makefile|sed -e 's,sat/,,' -e 's,/makefile,,'`" 11 | 12 | ## Uncomment and update to only build selected solver-app pairs 13 | #apps="genipalsp genipaessentials" 14 | # sats="picosat961" 15 | 16 | [ x"$sats" = x ] && die "no 'sat/*/makefile' found" 17 | for app in $apps 18 | do 19 | for sat in $sats 20 | do 21 | msg "scripts/mkone.sh $app $sat" 22 | scripts/mkone.sh $app $sat 23 | done 24 | done 25 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/hardware_model_checking/runSingle: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | 4 | zipFile="$1" 5 | problemFile="$2" 6 | solver="$3" 7 | option="$4" 8 | 9 | solver="$DIR/../../bin/incplan-${solver}" 10 | 11 | mkdir -p "$problemFile/$option" 12 | cd "$problemFile/$option" 13 | 14 | printf $DIR/runSingle > result 15 | for i in "$@"; do 16 | printf \ \'"$i"\' >> result 17 | done 18 | printf \\n >> result 19 | 20 | unzip -p $zipFile $problemFile > problem.srt 21 | 22 | cmd="$solver problem.srt $option" 23 | /usr/bin/time -f 'completeTime=%e %S %U' bash -c "ulimit -St 300 -Sv 8388608; $cmd" &>> result 24 | rm problem.srt -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/ipasir/test/mock_ipasir_cpp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "gmock/gmock.h" 3 | #include "ipasir/ipasir_cpp.h" 4 | 5 | namespace ipasir { 6 | class MockIpasir: public Ipasir { 7 | public: 8 | MOCK_METHOD0(signature, std::string ()); 9 | MOCK_METHOD1(add, void (int lit_or_zero)); 10 | MOCK_METHOD1(assume, void (int lit)); 11 | MOCK_METHOD0(solve, ipasir::SolveResult ()); 12 | MOCK_METHOD1(val, int (int lit)); 13 | MOCK_METHOD1(failed, int (int lit)); 14 | MOCK_METHOD1(set_terminate, void (std::function callback)); 15 | MOCK_METHOD2(set_learn, void (int max_length, std::function callback)); 16 | MOCK_METHOD0(reset, void ()); 17 | }; 18 | } -------------------------------------------------------------------------------- /app/genipamax/buildPblib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | die () { 4 | echo "*** buildPblib.sh: $*" 1>&2 5 | exit 1 6 | } 7 | 8 | msg () { 9 | echo "buildPblib.sh: $*" 10 | } 11 | 12 | checkbin () { 13 | $1 $2 1>/dev/null 2>/dev/null || \ 14 | die "execution of '$1 $2' failed ('$1' required)" 15 | } 16 | 17 | checkbin tar --help 18 | checkbin g++ --version 19 | checkbin cmake --version 20 | 21 | if [ -d pblib ] 22 | then 23 | msg "Removing PBLib (consider using 'ccache' for faster rebuild)" 24 | rm -rf pblib 25 | fi 26 | 27 | msg "Unpacking PBLib" 28 | #mkdir pblib 29 | #tar xvf pblib.tgz -C pblib 30 | tar xvf pblib.tar.gz 31 | 32 | msg "Building PBLib" 33 | cd pblib 34 | cmake -Wno-dev . 35 | make 36 | cd .. 37 | -------------------------------------------------------------------------------- /app/genipaessentials/README: -------------------------------------------------------------------------------- 1 | Given a satisfiable formula F and a variable x, we say that x is 2 | essential for the satisfiability of F if a truth value (True or False) 3 | must be assigned to x in each satisfying assignment of F. This application 4 | finds all the variables essential for the satisfiability of a given formula. 5 | 6 | The algorithm tests each variable one by one on the dual-rail encoded 7 | formula. Each test is done using two assumptions which represent the 8 | constraint that the given variable must not be assigned. 9 | 10 | The same application is implemented in Java (in the APPJAVA folder) to 11 | demonstrate the usage of an IPASIR solver in a Java application. 12 | 13 | Tomas Balyo 14 | KIT, Karlsruhe 15 | 3.2.2015 16 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/carj/ScopedTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "json.hpp" 4 | #include "logging.h" 5 | 6 | namespace carj { 7 | using json = nlohmann::json; 8 | 9 | class ScopedTimer { 10 | public: 11 | ScopedTimer(json::reference _target) : target{_target}{ 12 | start = std::chrono::high_resolution_clock::now(); 13 | } 14 | 15 | ~ScopedTimer(){ 16 | auto duration = std::chrono::duration_cast>(std::chrono::high_resolution_clock::now() - start); 17 | target = duration.count(); 18 | LOG(INFO) << duration.count() << "s"; 19 | } 20 | 21 | private: 22 | json::reference target; 23 | std::chrono::time_point start; 24 | }; 25 | } -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | CmdLineInterface.h \ 6 | ArgException.h \ 7 | CmdLine.h \ 8 | XorHandler.h \ 9 | MultiArg.h \ 10 | UnlabeledMultiArg.h \ 11 | ValueArg.h \ 12 | UnlabeledValueArg.h \ 13 | Visitor.h Arg.h \ 14 | HelpVisitor.h \ 15 | SwitchArg.h \ 16 | MultiSwitchArg.h \ 17 | VersionVisitor.h \ 18 | IgnoreRestVisitor.h \ 19 | CmdLineOutput.h \ 20 | StdOutput.h \ 21 | DocBookOutput.h \ 22 | ZshCompletionOutput.h \ 23 | OptionalUnlabeledTracker.h \ 24 | Constraint.h \ 25 | ValuesConstraint.h \ 26 | ArgTraits.h \ 27 | StandardTraits.h 28 | 29 | -------------------------------------------------------------------------------- /scripts/mkone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | die () { 3 | echo "*** mkone: $*" 1>&2 4 | exit 1 5 | } 6 | dchk () { 7 | [ -d $1 ] || die "can not find directory '$1'" 8 | } 9 | fchk () { 10 | [ -f $1 ] || die "can not find file '$1'" 11 | } 12 | [ $# = 2 ] || die "expected two arguments but got $#" 13 | msg () { 14 | echo "[mkone.sh] $*" 15 | } 16 | app=$1; sat=$2 17 | dchk app/$app 18 | fchk app/$app/makefile 19 | dchk sat/$sat 20 | fchk sat/$sat/makefile 21 | target=${app}-${sat} 22 | msg "building SAT solver '$sat'" 23 | make -C sat/$sat/ all 24 | msg "building and linking application '$app' against '$sat'" 25 | IPASIRSOLVER=$sat \ 26 | make -C app/$app/ all 27 | [ -f app/$app/$app ] || die "could not build 'app/$app/$app'" 28 | install -s app/$app/$app bin/$target 29 | msg "generated target 'bin/$target'" 30 | -------------------------------------------------------------------------------- /sat/minisat220/README: -------------------------------------------------------------------------------- 1 | Integrated a couple of patches into minisat-220.tar.gz in order to increase compatibilty. 2 | The additional patches/commits can be retraced here: https://github.com/Udopia/minisat/. 3 | 4 | Markus Iser 5 | 24-03-2020 6 | 7 | 8 | This is MiniSAT Version 2.2.0, directly obtained from 'github' on December 19, 2014. 9 | Then I have just unpacked the 'minisat-master.zip' file renamed the directory to 10 | 'minisat-220' to match the 'picosat' package name format and produced a 11 | GNU zipped tar file 'minisat-220.tar.gz'. Then I copied the makefile from 12 | 'picosat960/makefile', adapted it and provided glue code. For MiniSAT we 13 | need to 'libz-dev' installed. This library dependency is specified in 'LIBS'. 14 | Since all is C++ code, we also need to use 'g++' for linking, thus 'LINK' 15 | contains 'g++'. 16 | 17 | Armin Biere 18 | Fre Dez 19 21:05:29 CET 2014 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | ipasir.h reentrant incremental sat solver API (reverse) 3 | 4 | makefile with goals 'all' and 'clean' 5 | 6 | scripts/mkone.sh produces one combination of an application and a SAT solver 7 | scripts/mkall.sh produces all combinations 8 | scripts/mkcln.sh cleans up everything 9 | 10 | app application directory 11 | sat SAT solver directory 12 | bin binaries of all combinations 13 | 14 | sat/README explains the SAT solver directory 15 | app/README explains the apps directory 16 | 17 | LICENSE generic license for parts of this software not 18 | explicitly covered by its own license restrictions, 19 | which can be found in the corresponding LICENSE or 20 | COPYRIGHT file in a sub directory or in a distribution 21 | package, such as in an included tar or zip file 22 | ``` -------------------------------------------------------------------------------- /app/incplan/src/incplan/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Stephan Gocht 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2003 Michael E. Smoot 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 20 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/runSrt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | srt="java -Xmx8G -jar $DIR/../bin/srt.jar" 5 | 6 | i=0 7 | splitPoint=0 8 | for param in "$@" 9 | do 10 | i=$((i + 1)) 11 | case $param in 12 | ::) 13 | splitPoint=$i 14 | ;; 15 | esac 16 | done 17 | 18 | problem="${@:1:1}" 19 | domain="$( dirname "${problem}" )/domain.pddl" 20 | 21 | $DIR/../../fast-downward/src/translate/translate.py $domain $problem 22 | problem="output.sas" 23 | 24 | if [ $splitPoint != 0 ]; then 25 | srtArgs="${@:2:$((splitPoint - 2))}" 26 | incplanArgs="${@:$((splitPoint + 1))}" 27 | 28 | incplanInput="problem.in" 29 | incplanOutput="problem.out" 30 | 31 | cmd="$srt $srtArgs $problem > $incplanInput" 32 | echo $cmd 33 | eval $cmd 34 | 35 | cmd="$incplanArgs $incplanInput > ${incplanOutput}.all" 36 | echo $cmd 37 | /usr/bin/time -f "solvingTime=%e %S %U" bash -c "ulimit -Sv 8388608; $cmd" 38 | 39 | if [ "$?" -eq 0 ]; then 40 | grep '^ci' "${incplanOutput}.all" 41 | grep -v '^c' ${incplanOutput}.all | grep -v -e '^$' > $incplanOutput 42 | cmd="$srt check $srtArgs $problem $incplanOutput" 43 | echo $cmd 44 | eval $cmd 45 | fi 46 | 47 | else 48 | echo "Srt cant solve problems alone please provide incplan" 49 | fi -------------------------------------------------------------------------------- /app/genipafolio/Threading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Threading.h 3 | * 4 | * Created on: Nov 25, 2014 5 | * Author: Tomas Balyo, KIT, Karlsruhe 6 | */ 7 | 8 | #ifndef THREADING_H_ 9 | #define THREADING_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define TESTRUN(cmd, msg) int res = cmd; if (res != 0) { printf(msg,res); exit(res); } 16 | 17 | class Mutex { 18 | private: 19 | pthread_mutex_t mtx; 20 | public: 21 | Mutex() { 22 | TESTRUN(pthread_mutex_init(&mtx, NULL), "Mutex init failed with msg %d\n") 23 | } 24 | virtual ~Mutex() { 25 | TESTRUN(pthread_mutex_destroy(&mtx), "Mutex destroy failed with msg %d\n") 26 | } 27 | void lock() { 28 | TESTRUN(pthread_mutex_lock(&mtx), "Mutex lock failed with msg %d\n") 29 | } 30 | void unlock() { 31 | TESTRUN(pthread_mutex_unlock(&mtx), "Mutex unlock failed with msg %d\n") 32 | } 33 | bool tryLock() { 34 | // return true if lock acquired 35 | return pthread_mutex_trylock(&mtx) == 0; 36 | } 37 | }; 38 | 39 | class Thread { 40 | private: 41 | pthread_t thread; 42 | public: 43 | Thread(void*(*method)(void*), void* arg) { 44 | pthread_create(&thread, NULL, method, arg); 45 | } 46 | void join() { 47 | pthread_join(thread, NULL); 48 | } 49 | }; 50 | 51 | 52 | 53 | #endif /* THREADING_H_ */ 54 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/README.md: -------------------------------------------------------------------------------- 1 | # incplan 2 | Tool to do SAT Based Planning using an incremental SAT solver. 3 | 4 | ## Preparation 5 | Get a sat solver implementing the ipasir api. 6 | I.e. from http://baldur.iti.kit.edu/sat-race-2015/downloads/ipasir.zip 7 | Drop the sat solver library implementing the ipasir api in lib/ipasir 8 | 9 | ## Building 10 | ``` 11 | cd build 12 | cmake ../src 13 | make 14 | ``` 15 | 16 | The binaries will now be in bin/ 17 | 18 | ## Running 19 | To show the help you can run without parameters: 20 | ``` 21 | incplan-[solvername] 22 | ``` 23 | To run with default settings: 24 | ``` 25 | incplan-[solvername] [problemFile] 26 | ``` 27 | 28 | The problem file should be encoded in dimspec. It contains four sections: 29 | ``` 30 | i cnf [numberVariables] [numberclauses] 31 | [initial clauses in dimacs cnf] 32 | u cnf [numberVariables] [numberclauses] 33 | [universal/invariant clauses in dimacs cnf] 34 | g cnf [numberVariables] [numberclauses] 35 | [goal clauses in dimacs cnf] 36 | t cnf [numberVariables] [numberclauses] 37 | [transition clauses in dimacs cnf] 38 | ``` 39 | The order of iugt is relevant. The number of variables/ clauses is only for the 40 | section. 41 | 42 | ## Experiments 43 | 44 | For information about the experiments of our icaps17 paper submission see 45 | experiment/icaps17/README 46 | -------------------------------------------------------------------------------- /app/ipasir-check-satunsat/README: -------------------------------------------------------------------------------- 1 | A binary that calls a solver with a fixed formula many times with a full stack 2 | of assumption literals. The constructed formula has only a single solution. 3 | All further calls should result in no solution. Whenever a conflict is returned by 4 | the IPASIR solver, this conflict is added to the formula as well. 5 | As a full assumption stack is used, each single call to the solver is very simple, 6 | as all variables could be assigned right away and then the solution can be checked. 7 | The binary reports the calls per seconds that the solver could run. 8 | 9 | The binary takes 3 parameters: X Y Z 10 | 11 | X is the number of calls to be performed, where the signes of the literals in the assumption list correspond to the binary representation of the number of the call. Set bits correspond to negative literals. 12 | 13 | Y is the number of variables of a basic block in a formula. The basic block is encoded as all possible clauses over the given variables, except that the clause with all negative variables is not added to the formula (making the basic block satisfiable). 14 | 15 | Z is the number of basic blocks in the formula. Essentially, basic block number i starts with variable (i*Y)+1. Hence, the maximum variable of the formula is Y * Z. 16 | 17 | The maximum number of clauses in the formula is (2^Y - 1) * Z. 18 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/README: -------------------------------------------------------------------------------- 1 | A binary that calls a solver with a fixed formula many times with a full stack 2 | of assumption literals. The constructed formula has only a single solution. 3 | All further calls should result in no solution. Whenever a conflict is returned by 4 | the IPASIR solver, this conflict is added to the formula as well. 5 | As a full assumption stack is used, each single call to the solver is very simple, 6 | as all variables could be assigned right away and then the solution can be checked. 7 | The binary reports the calls per seconds that the solver could run. 8 | 9 | The binary takes 3 parameters: X Y Z 10 | 11 | X is the number of calls to be performed, where the signes of the literals in the assumption list correspond to the binary representation of the number of the call. Set bits correspond to negative literals. 12 | 13 | Y is the number of variables of a basic block in a formula. The basic block is encoded as all possible clauses over the given variables, except that the clause with all negative variables is not added to the formula (making the basic block satisfiable). 14 | 15 | Z is the number of basic blocks in the formula. Essentially, basic block number i starts with variable (i*Y)+1. Hence, the maximum variable of the formula is Y * Z. 16 | 17 | The maximum number of clauses in the formula is (2^Y - 1) * Z. 18 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/runSingleMadagascar: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | 4 | zipFile="$1" 5 | problemFile="$2" 6 | option="$3" 7 | 8 | folder="$(dirname $problemFile)" 9 | parentDirectory="$(dirname $folder)" 10 | 11 | problem="$(basename $problemFile)" 12 | problem="${problem%.*}" 13 | 14 | domain="$(basename $folder)" 15 | track="$(basename $parentDirectory)" 16 | 17 | domainFile="$folder/domain.pddl" 18 | domainFile2="${folder}/domain_${problem}.pddl" 19 | 20 | case $option in 21 | "M") 22 | conf="M" 23 | ;; 24 | "P") 25 | toolOption="" 26 | conf="MpC" 27 | ;; 28 | *) 29 | echo "unnown option" 30 | exit 1 31 | ;; 32 | esac 33 | 34 | tool="$DIR/runMadagascar" 35 | 36 | mkdir -p "$track/$domain/$problem/$conf" 37 | cd "$track/$domain/$problem/$conf" 38 | touch result 39 | 40 | unzip -p $zipFile $domainFile > domain.pddl 41 | #if empty use alternate location 42 | if [ ! -s domain.pddl ] ; then 43 | unzip -p $zipFile $domainFile2 > domain.pddl 44 | fi 45 | unzip -p $zipFile $problemFile > problem.pddl 46 | 47 | solver="$DIR/../bin/incplan-picosat961" 48 | 49 | cmd="$tool problem.pddl $toolOption" 50 | /usr/bin/time -f 'completeTime=%e %S %U' bash -c "ulimit -St 300; $cmd" &> result 51 | rm -f domain.pddl problem.pddl output.sas problem.in problem.in.cnf problem.out problem.out.all gmon.out -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/CMake/gtest.cmake: -------------------------------------------------------------------------------- 1 | # Download and unpack googletest at configure time 2 | configure_file(${CMAKE_SOURCE_DIR}/CMake/gtest-download.cmake googletest-download/CMakeLists.txt) 3 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 4 | RESULT_VARIABLE result 5 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 6 | if(result) 7 | message(FATAL_ERROR "CMake step for googletest failed: ${result}") 8 | endif() 9 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 10 | RESULT_VARIABLE result 11 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) 12 | if(result) 13 | message(FATAL_ERROR "Build step for googletest failed: ${result}") 14 | endif() 15 | 16 | # Prevent overriding the parent project's compiler/linker 17 | # settings on Windows 18 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 19 | 20 | # Add googletest directly to our build. This defines 21 | # the gtest and gtest_main targets. 22 | add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src 23 | ${CMAKE_BINARY_DIR}/googletest-build) 24 | 25 | # The gtest/gtest_main targets carry header search path 26 | # dependencies automatically when using CMake 2.8.11 or 27 | # later. Otherwise we have to add them here ourselves. 28 | if (CMAKE_VERSION VERSION_LESS 2.8.11) 29 | include_directories("${gtest_SOURCE_DIR}/include") 30 | endif() -------------------------------------------------------------------------------- /sat/lingelingbcj/ipasirlingelingglue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Lingeling.cpp 3 | * 4 | * Created on: Dec 4, 2014 5 | * Author: balyo 6 | */ 7 | 8 | 9 | #include "ipasir.h" 10 | 11 | extern "C" { 12 | #include "lingeling-bcj/lglib.h" 13 | } 14 | 15 | const char* ipasir_signature() { 16 | return lglversion(); 17 | } 18 | 19 | void* ipasir_init() { 20 | return lglinit(); 21 | } 22 | 23 | void ipasir_release(void* solver) { 24 | lglrelease((LGL*)solver); 25 | } 26 | 27 | void ipasir_add(void* solver, int32_t lit) { 28 | if (lit != 0) { 29 | lglfreeze((LGL*)solver, lit); 30 | } 31 | lgladd((LGL*)solver, lit); 32 | } 33 | 34 | void ipasir_assume(void* solver, int32_t lit) { 35 | lglfreeze((LGL*)solver, lit); 36 | lglassume((LGL*)solver, lit); 37 | } 38 | 39 | int ipasir_solve(void* solver) { 40 | return lglsat((LGL*)solver); 41 | } 42 | 43 | int ipasir_val(void * solver, int32_t var) { 44 | return var*lglderef((LGL*)solver, var); 45 | } 46 | 47 | int ipasir_failed(void * solver, int32_t lit) { 48 | return lglfailed((LGL*)solver, lit); 49 | } 50 | 51 | void ipasir_set_terminate(void * solver, void * state, int (*terminate)(void * state)) { 52 | lglseterm((LGL*)solver, terminate, state); 53 | } 54 | 55 | void ipasir_set_learn (void * solver, void * state, int max_length, void (*learn)(void * state, int32_t * clause)) { 56 | //not implemented 57 | } 58 | -------------------------------------------------------------------------------- /sat/minisat220/minisat-cc.patch: -------------------------------------------------------------------------------- 1 | --- minisat-220/minisat/core/Solver.cc 2013-09-25 14:16:18.000000000 +0200 2 | +++ patched-minisat-220/minisat/core/Solver.cc 2017-05-04 09:46:29.256352793 +0200 3 | @@ -53,9 +53,10 @@ 4 | 5 | Solver::Solver() : 6 | 7 | + termCallback (NULL), learnCallbackBuffer (NULL), learnCallback (NULL) 8 | // Parameters (user settable): 9 | // 10 | - verbosity (0) 11 | + , verbosity (0) 12 | , var_decay (opt_var_decay) 13 | , clause_decay (opt_clause_decay) 14 | , random_var_freq (opt_random_var_freq) 15 | @@ -106,6 +107,7 @@ 16 | 17 | Solver::~Solver() 18 | { 19 | + free(this->learnCallbackBuffer); 20 | } 21 | 22 | 23 | @@ -717,6 +719,16 @@ 24 | learnt_clause.clear(); 25 | analyze(confl, learnt_clause, backtrack_level); 26 | cancelUntil(backtrack_level); 27 | + 28 | + 29 | + if (learnCallback != 0 && learnt_clause.size() <= learnCallbackLimit) { 30 | + for (int i = 0; i < learnt_clause.size(); i++) { 31 | + Lit lit = learnt_clause[i]; 32 | + learnCallbackBuffer[i] = sign(lit) ? -(var(lit)+1) : (var(lit)+1); 33 | + } 34 | + learnCallbackBuffer[learnt_clause.size()] = 0; 35 | + learnCallback(learnCallbackState, learnCallbackBuffer); 36 | + } 37 | 38 | if (learnt_clause.size() == 1){ 39 | uncheckedEnqueue(learnt_clause[0]); 40 | -------------------------------------------------------------------------------- /app/incplan/README: -------------------------------------------------------------------------------- 1 | This benchmark solves planning problems incrementally. Each instance of a 2 | planning problem can be described as: 3 | 4 | - initial clauses I: satisfied in the initial statet t[0] 5 | - goal clauses G: satisfied in the goal state t[i] 6 | - universal clauses U: satisfied at every time point t[k] 7 | - transition clauses T : satisfied at each pair of consecutive time point t[k], 8 | t[k+1] 9 | 10 | The instances have been generated from a subset of the benchmarks of the 11 | Planning Competition (IPC) 2014 with help of a modified version of the planner 12 | madagascar [1,3]. 13 | 14 | The problems are encoded using the double ended incremental encoding. Details 15 | can be found in [2]. 16 | 17 | 18 | 19 | The software is available via GitHub [4]. 20 | 21 | Stephan Gocht 22 | stephan.gocht@student.kit.edu 23 | 09.05.2017 24 | 25 | [1] Planning as satisfiability: parallel plans and algorithms for plan search, 26 | Rintanen, J.; Heljanko, K.; and Niemelä, I., 2006 Artificial Intelligence 27 | 28 | [2] Accelerating SAT Based Planning with Incremental SAT Solving, Stephan Gocht 29 | and Tomas Balyo, 2017 The 27th International Conference on Automated Planning 30 | and Scheduling 31 | 32 | [3] https://users.ics.aalto.fi/rintanen/satplan.html 33 | 34 | [4] Latest: 35 | https://github.com/StephanGocht/incplan 36 | 37 | Based on Commit: 38 | 9413714018436313b606b986f373a15ba612e8f2 39 | https://github.com/StephanGocht/incplan/tree/9413714018436313b606b986f373a15ba612e8f2 40 | 41 | -------------------------------------------------------------------------------- /sat/picosat961/ipasirpicosatglue.c: -------------------------------------------------------------------------------- 1 | #include "ipasir.h" 2 | #include "picosat.h" 3 | 4 | static const char * sig = "picosat" VERSION; 5 | 6 | const char * ipasir_signature () { return sig; } 7 | 8 | void * ipasir_init () { 9 | char prefix[80]; 10 | void * res = picosat_init (); 11 | sprintf (prefix, "c [%s] ", sig); 12 | picosat_set_prefix (res, prefix); 13 | picosat_set_verbosity (res, 1); 14 | picosat_set_output (res, stdout); 15 | return res; 16 | } 17 | 18 | void ipasir_release (void * solver) { 19 | picosat_stats (solver); 20 | picosat_reset (solver); 21 | } 22 | 23 | void ipasir_add (void * solver, int32_t lit) { picosat_add (solver, lit); } 24 | 25 | void ipasir_assume (void * solver, int32_t lit) { picosat_assume (solver, lit); } 26 | 27 | int ipasir_solve (void * solver) { return picosat_sat (solver, -1); } 28 | 29 | int ipasir_failed (void * solver, int32_t lit) { 30 | return picosat_failed_assumption (solver, lit); 31 | } 32 | 33 | int ipasir_val (void * solver, int32_t var) { 34 | int val = picosat_deref (solver, var); 35 | if (!val) return 0; 36 | return val < 0 ? -var : var; 37 | } 38 | 39 | void 40 | ipasir_set_terminate ( 41 | void * solver, 42 | void * state, int (*terminate)(void * state)) { 43 | picosat_set_interrupt (solver, state, terminate); 44 | } 45 | 46 | /* Picosat does not implement clause sharing functionality */ 47 | void ipasir_set_learn (void * solver, void * state, int max_length, void (*learn)(void * state, int32_t * clause)) {} 48 | 49 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/icaps17/README: -------------------------------------------------------------------------------- 1 | 1) Viewing the benchmark results 2 | To view the benchmark results you need jupyter notebook. The resultAnalysis.ipynb file contains all scripts used to evaluate the colleted result data icaps17-benchmark.txt. 3 | 4 | 2) Reproduce the experiments from the icaps 2017 paper 5 | 6 | To reproduce the experiment make sure to check out commit f951c76b5cf97bf96. 7 | 8 | 2.1) Planning Tools 9 | 2.1.1) Madgascar 10 | Get madagascar from https://users.ics.aalto.fi/rintanen/satplan.html the February 25, 2015 version of the source code was used. 11 | 12 | Apply the patch provided (./madagascarPatch.diff) and compile madagascar. Then move MpC to the bin directory of this repository. 13 | 14 | 2.1.2) Freelunch 15 | Is already provided in this repository. (bin/srt.jar) 16 | 17 | 2.2) Sat solver 18 | Get the incremental sat solvers from the 2016 SAT competition: 19 | http://baldur.iti.kit.edu/sat-competition-2016/downloads/incremental.zip 20 | 21 | compile the cominisatps2sun_nopre solver and copy libipasircominisatps2sun_nopre.a to lib/ipasir/ 22 | 23 | now compile incplan: 24 | cd incplan/build 25 | make 26 | 27 | 2.3) Planning Domains 28 | Get the planning problems zip files from the 2014 IPC: 29 | https://helios.hud.ac.uk/scommv/IPC-14/repository/benchmarksV1.1.zip 30 | 31 | 2.4) Running the Benchmarks 32 | Run: 33 | experiment/icaps17/runExperiment [pathToPlanningZip] 34 | experiment/icaps17/collectData 35 | 36 | You should now have a collectedData.txt, which can be analyzed with the jupyter notebook (see 1) -------------------------------------------------------------------------------- /app/genipalsp/inputs/maze-10-0.5-8.grid: -------------------------------------------------------------------------------- 1 | p sp 100 100 2 | a 1 11 1 3 | a 4 14 1 4 | a 4 5 1 5 | a 5 15 1 6 | a 5 4 1 7 | a 5 6 1 8 | a 6 16 1 9 | a 6 5 1 10 | a 9 19 1 11 | a 11 1 1 12 | a 11 12 1 13 | a 12 11 1 14 | a 12 13 1 15 | a 13 12 1 16 | a 13 14 1 17 | a 14 4 1 18 | a 14 13 1 19 | a 14 15 1 20 | a 15 5 1 21 | a 15 25 1 22 | a 15 14 1 23 | a 15 16 1 24 | a 16 6 1 25 | a 16 26 1 26 | a 16 15 1 27 | a 19 9 1 28 | a 19 20 1 29 | a 20 19 1 30 | a 25 15 1 31 | a 25 35 1 32 | a 25 26 1 33 | a 26 16 1 34 | a 26 36 1 35 | a 26 25 1 36 | a 26 27 1 37 | a 27 37 1 38 | a 27 26 1 39 | a 34 35 1 40 | a 35 25 1 41 | a 35 34 1 42 | a 35 36 1 43 | a 36 26 1 44 | a 36 35 1 45 | a 36 37 1 46 | a 37 27 1 47 | a 37 47 1 48 | a 37 36 1 49 | a 47 37 1 50 | a 47 57 1 51 | a 47 48 1 52 | a 48 58 1 53 | a 48 47 1 54 | a 52 62 1 55 | a 52 53 1 56 | a 53 63 1 57 | a 53 52 1 58 | a 53 54 1 59 | a 54 64 1 60 | a 54 53 1 61 | a 57 47 1 62 | a 57 58 1 63 | a 58 48 1 64 | a 58 68 1 65 | a 58 57 1 66 | a 61 62 1 67 | a 62 52 1 68 | a 62 72 1 69 | a 62 61 1 70 | a 62 63 1 71 | a 63 53 1 72 | a 63 62 1 73 | a 63 64 1 74 | a 64 54 1 75 | a 64 63 1 76 | a 64 65 1 77 | a 65 64 1 78 | a 65 66 1 79 | a 66 65 1 80 | a 68 58 1 81 | a 68 69 1 82 | a 69 79 1 83 | a 69 68 1 84 | a 72 62 1 85 | a 72 82 1 86 | a 79 69 1 87 | a 79 89 1 88 | a 81 82 1 89 | a 82 72 1 90 | a 82 92 1 91 | a 82 81 1 92 | a 82 83 1 93 | a 83 82 1 94 | a 83 84 1 95 | a 84 83 1 96 | a 89 79 1 97 | a 89 90 1 98 | a 90 100 1 99 | a 90 89 1 100 | a 92 82 1 101 | a 100 90 1 102 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Vistor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /sat/minisat220/minisat-h.patch: -------------------------------------------------------------------------------- 1 | --- minisat-220/minisat/core/Solver.h 2013-09-25 14:16:18.000000000 +0200 2 | +++ patched-minisat-220/minisat/core/Solver.h 2017-05-04 09:44:27.285080162 +0200 3 | @@ -37,6 +37,24 @@ 4 | class Solver { 5 | public: 6 | 7 | + void* termCallbackState; 8 | + int (*termCallback)(void* state); 9 | + void setTermCallback(void* state, int (*termCallback)(void*)) { 10 | + this->termCallbackState = state; 11 | + this->termCallback = termCallback; 12 | + } 13 | + 14 | + void* learnCallbackState; 15 | + int* learnCallbackBuffer; 16 | + int learnCallbackLimit; 17 | + void (*learnCallback)(void * state, int * clause); 18 | + void setLearnCallback(void * state, int maxLength, void (*learn)(void * state, int * clause)) { 19 | + this->learnCallbackState = state; 20 | + this->learnCallbackLimit = maxLength; 21 | + this->learnCallbackBuffer = (int*) realloc (this->learnCallbackBuffer, (1+maxLength)*sizeof(int)); 22 | + this->learnCallback = learn; 23 | + } 24 | + 25 | // Constructor/Destructor: 26 | // 27 | Solver(); 28 | @@ -372,7 +390,7 @@ 29 | inline void Solver::clearInterrupt(){ asynch_interrupt = false; } 30 | inline void Solver::budgetOff(){ conflict_budget = propagation_budget = -1; } 31 | inline bool Solver::withinBudget() const { 32 | - return !asynch_interrupt && 33 | + return !asynch_interrupt && (termCallback == NULL || 0 == termCallback(termCallbackState)) && 34 | (conflict_budget < 0 || conflicts < (uint64_t)conflict_budget) && 35 | (propagation_budget < 0 || propagations < (uint64_t)propagation_budget); } 36 | 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This LICENSE applies to all software included in the IPASIR distribution, 2 | except for those parts in sub-directories or in included software 3 | distribution packages, such as tar and zip files, which have their own 4 | license restrictions. Those license restrictions are usually listed in the 5 | corresponding LICENSE or COPYING files, either in the sub-directory or in 6 | the included software distribution package (the tar or zip file). Please 7 | refer to those licenses for rights to use that software. 8 | 9 | Copyright (c) 2014, Tomas Balyo, Karlsruhe Institute of Technology. 10 | Copyright (c) 2014, Armin Biere, Johannes Kepler University. 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy 13 | of this software and associated documentation files (the "Software"), to 14 | deal in the Software without restriction, including without limitation the 15 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | sell copies of the Software, and to permit persons to whom the Software is 17 | furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in 20 | all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 28 | IN THE SOFTWARE. 29 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/runMadagascar: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -A 1 Algoritm A with paralelity 1 (so basically sequential) 3 | # -S 1 test each step separately 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | #madagascar=$DIR/../bin/MpC 6 | madagascar="$DIR/../bin/M" 7 | 8 | i=0 9 | splitPoint=0 10 | for param in "$@" 11 | do 12 | i=$((i + 1)) 13 | case $param in 14 | ::) 15 | splitPoint=$i 16 | ;; 17 | esac 18 | done 19 | 20 | problem="${@:1:1}" 21 | domain="$( dirname "${problem}" )/domain.pddl" 22 | 23 | if [ $splitPoint != 0 ]; then 24 | madagascarArgs="${@:2:$((splitPoint - 2))}" 25 | incplanArgs="${@:$((splitPoint + 1))}" 26 | 27 | incplanInput="problem.in" 28 | incplanOutput="problem.out" 29 | 30 | cmd="$madagascar $domain $problem -m 8192 -t 300 $madagascarArgs -b $incplanInput -L" 31 | echo "" 32 | echo $cmd 33 | eval $cmd 34 | incplanInput="$incplanInput.cnf" 35 | 36 | cmd="$incplanArgs --outputSolverLike $incplanInput > ${incplanOutput}.all" 37 | echo "" 38 | echo $cmd 39 | /usr/bin/time -f "solvingTime=%e %S %U" bash -c "ulimit -Sv 8388608; $cmd" 40 | if [ "$?" -eq 0 ]; then 41 | 42 | #print comments from incplan 43 | grep '^ci' "${incplanOutput}.all" 44 | grep -v '^c' ${incplanOutput}.all | grep -v -e '^$' > $incplanOutput 45 | 46 | #extract the step size from the result 47 | header=($(head -n 1 $incplanOutput)) 48 | varsPerTime="${header[1]}" 49 | steps="${header[2]}" 50 | echo "plan size: $steps" 51 | echo "vars per time: $varsPerTime" 52 | steps=$((steps-1)) 53 | sed -i '1d' "$incplanOutput" 54 | 55 | cmd="$madagascar $domain $problem -m 8192 -t 300 $madagascarArgs -s $incplanOutput -T $steps" 56 | echo "" 57 | echo $cmd 58 | eval $cmd 59 | fi 60 | else 61 | cmd="$madagascar $domain $problem ${@:2}" 62 | /usr/bin/time -f "solvingTime=%e %S %U" bash -c "$cmd" 63 | fi 64 | echo "" -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: OptionalUnlabeledTracker.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 25 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 26 | 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | class OptionalUnlabeledTracker 32 | { 33 | 34 | public: 35 | 36 | static void check( bool req, const std::string& argName ); 37 | 38 | static void gotOptional() { alreadyOptionalRef() = true; } 39 | 40 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 41 | 42 | private: 43 | 44 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 45 | }; 46 | 47 | 48 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 49 | { 50 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 51 | throw( SpecificationException( 52 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 53 | argName ) ); 54 | 55 | if ( !req ) 56 | OptionalUnlabeledTracker::gotOptional(); 57 | } 58 | 59 | 60 | } // namespace TCLAP 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/ipasirprint.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | #include "ipasir/ipasir.h" 3 | } 4 | 5 | #include 6 | #include 7 | #include "misc.h" 8 | 9 | using namespace incplan; 10 | 11 | extern "C" { 12 | #define SAT 10 13 | #define UNSAT 20 14 | #define TIMEOUT 0 15 | 16 | const char * ipasir_signature (){ 17 | return "printing all clauses"; 18 | } 19 | 20 | void * ipasir_init (){ 21 | return nullptr; 22 | } 23 | 24 | void ipasir_release (void * solver){ 25 | UNUSED(solver); 26 | } 27 | 28 | void ipasir_add (void * solver, int lit_or_zero){ 29 | UNUSED(solver); 30 | std::cout << lit_or_zero << " "; 31 | if (lit_or_zero == 0) { 32 | std::cout << std::endl; 33 | } 34 | } 35 | 36 | void ipasir_assume (void * solver, int lit){ 37 | UNUSED(solver); 38 | std::cout << "a" << lit << " "; 39 | } 40 | 41 | int ipasir_solve (void * solver){ 42 | UNUSED(solver); 43 | std::cout << " solved? 0/1 [0]: "; 44 | bool solved = false; 45 | if (std::cin.peek() == '\n') { //check if next character is newline 46 | solved = false; //and assign the default 47 | } else if (!(std::cin >> solved)) { //be sure to handle invalid input 48 | std::cout << "Invalid input. Using default.\n"; 49 | std::cin.clear(); 50 | //error handling 51 | } 52 | 53 | std::cin.ignore( std::numeric_limits::max(), '\n' ); 54 | if (solved) { 55 | return SAT; 56 | } else { 57 | return UNSAT; 58 | } 59 | } 60 | 61 | int ipasir_val (void * solver, int lit){ 62 | UNUSED(solver); 63 | UNUSED(lit); 64 | return 0; 65 | } 66 | 67 | 68 | int ipasir_failed (void * solver, int lit){ 69 | UNUSED(solver); 70 | UNUSED(lit); 71 | return 0; 72 | } 73 | 74 | void ipasir_set_terminate (void * solver, void * state, int (*terminate)(void * state)){ 75 | UNUSED(solver); 76 | UNUSED(state); 77 | UNUSED(terminate); 78 | } 79 | 80 | void ipasir_set_learn (void * solver, void * state, int max_length, void (*learn)(void * state, int * clause)){ 81 | UNUSED(solver); 82 | UNUSED(state); 83 | UNUSED(max_length); 84 | UNUSED(learn); 85 | } 86 | 87 | } -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Constraint.h 5 | * 6 | * Copyright (c) 2005, Michael E. Smoot 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_CONSTRAINT_H 23 | #define TCLAP_CONSTRAINT_H 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace TCLAP { 33 | 34 | /** 35 | * The interface that defines the interaction between the Arg and Constraint. 36 | */ 37 | template 38 | class Constraint 39 | { 40 | 41 | public: 42 | /** 43 | * Returns a description of the Constraint. 44 | */ 45 | virtual std::string description() const =0; 46 | 47 | /** 48 | * Returns the short ID for the Constraint. 49 | */ 50 | virtual std::string shortID() const =0; 51 | 52 | /** 53 | * The method used to verify that the value parsed from the command 54 | * line meets the constraint. 55 | * \param value - The value that will be checked. 56 | */ 57 | virtual bool check(const T& value) const =0; 58 | 59 | /** 60 | * Destructor. 61 | * Silences warnings about Constraint being a base class with virtual 62 | * functions but without a virtual destructor. 63 | */ 64 | virtual ~Constraint() { ; } 65 | }; 66 | 67 | } //namespace TCLAP 68 | #endif 69 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/carj/carj.cpp: -------------------------------------------------------------------------------- 1 | #include "carj.h" 2 | #include 3 | 4 | #include "json.hpp" 5 | #include "carj/logging.h" 6 | 7 | 8 | INITIALIZE_EASYLOGGINGPP 9 | using json = nlohmann::json; 10 | 11 | const std::string carj::Carj::configPath = "carj.json"; 12 | 13 | carj::Carj& carj::getCarj() { 14 | static carj::Carj carj; 15 | return carj; 16 | } 17 | 18 | std::vector& carj::getArgs(){ 19 | static std::vector args; 20 | return args; 21 | } 22 | 23 | void initLogger(){ 24 | el::Configurations conf; 25 | conf.setToDefault(); 26 | conf.setGlobally(el::ConfigurationType::Format, "ci %level %fbase:%line; %msg"); 27 | conf.set(el::Level::Fatal, el::ConfigurationType::Format, "%level %fbase:%line; %msg"); 28 | el::Loggers::reconfigureAllLoggers(conf); 29 | 30 | conf.setGlobally(el::ConfigurationType::Format, "ci %level %datetime{%H:%m:%s}; %msg"); 31 | el::Loggers::reconfigureLogger("performance", conf); 32 | el::Loggers::setVerboseLevel(2); 33 | } 34 | 35 | void carj::init(int argc, const char **argv, TCLAP::CmdLine& cmd, 36 | std::string parameterBase) { 37 | START_EASYLOGGINGPP(argc, argv); 38 | initLogger(); 39 | 40 | std::array argv_help = {argv[0], "-h"}; 41 | if (argc == 1) { 42 | argc = 2; 43 | argv = argv_help.data(); 44 | } 45 | 46 | TCLAP::ValueArg configPath("", "configPath", 47 | /*description*/ "Path to configuartion file.", 48 | /*necessary*/ false, 49 | /*default*/ "carj.json", 50 | /*type descr.*/ "path"); 51 | cmd.add(configPath); 52 | 53 | TCLAP::SwitchArg useConfig("", "useConfig", 54 | "Use configuration file 'carj.json'.", 55 | /*default*/ false); 56 | cmd.add(useConfig); 57 | 58 | TCLAP::ValueArg jsonParameterBase("", "jsonParameterBase", 59 | "Json pointer to base of parameters.", 60 | /*necessary*/ false, 61 | /*default*/ parameterBase, 62 | /*description*/ ""); 63 | cmd.add(jsonParameterBase); 64 | 65 | cmd.parse( argc, argv ); 66 | 67 | carj::getCarj().init( 68 | configPath.getValue(), 69 | configPath.isSet() || useConfig.getValue(), 70 | jsonParameterBase.getValue()); 71 | carj::CarjArgBase::writeAllToJson(); 72 | 73 | 74 | } -------------------------------------------------------------------------------- /app/incplan/src/incplan/experiment/runSingleIncrementalExperiment: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 3 | 4 | zipFile="$1" 5 | problemFile="$2" 6 | tool="$3" 7 | option="$4" 8 | solver="$5" 9 | 10 | folder="$(dirname $problemFile)" 11 | parentDirectory="$(dirname $folder)" 12 | 13 | problem="$(basename $problemFile)" 14 | problem="${problem%.*}" 15 | 16 | domain="$(basename $folder)" 17 | track="$(basename $parentDirectory)" 18 | 19 | domainFile="$folder/domain.pddl" 20 | domainFile2="${folder}/domain_${problem}.pddl" 21 | 22 | 23 | conf="${solver}_${tool}_${option}" 24 | solver="$DIR/../bin/incplan-${solver}" 25 | 26 | case $tool in 27 | "MpC-e") 28 | #exist 29 | tool="$DIR/runMadagascar" 30 | toolOption="-P 2" 31 | ;; 32 | "MpC-a") 33 | #forall 34 | tool="$DIR/runMadagascar" 35 | toolOption="-P 1" 36 | ;; 37 | "MpC-s") 38 | #sequential 39 | tool="$DIR/runMadagascar" 40 | toolOption="-P 0" 41 | ;; 42 | "Srt-e") 43 | tool="$DIR/runSrt" 44 | toolOption="exist" 45 | ;; 46 | "Srt-r") 47 | tool="$DIR/runSrt" 48 | toolOption="reinforced" 49 | ;; 50 | "Srt-s") 51 | tool="$DIR/runSrt" 52 | toolOption="selective" 53 | ;; 54 | *) 55 | echo "unnown tool: >$tool<" 56 | exit 1 57 | ;; 58 | esac 59 | 60 | case $option in 61 | "n") 62 | option="-n" 63 | ;; 64 | "s") 65 | option="-s" 66 | ;; 67 | "r1") 68 | option="-r 1" 69 | ;; 70 | "r0.5") 71 | option="-r 0.5" 72 | ;; 73 | "r0.5-S5") 74 | option="-r 0.5 -S 5" 75 | ;; 76 | *) 77 | # echo "unnown option: $option" 78 | # exit 1 79 | ;; 80 | esac 81 | 82 | mkdir -p "$track/$domain/$problem/$conf" 83 | cd "$track/$domain/$problem/$conf" 84 | touch result 85 | 86 | unzip -p $zipFile $domainFile > domain.pddl 87 | #if empty use alternate location 88 | if [ ! -s domain.pddl ] ; then 89 | unzip -p $zipFile $domainFile2 > domain.pddl 90 | fi 91 | unzip -p $zipFile $problemFile > problem.pddl 92 | 93 | echo "$DIR/runSingleIncrementalExperiment $@" > result 94 | 95 | cmd="$tool problem.pddl $toolOption :: $solver $option" 96 | /usr/bin/time -f 'completeTime=%e %S %U' bash -c "ulimit -St 300; $cmd" &>> result 97 | #rm -f domain.pddl problem.pddl output.sas problem.in problem.in.cnf problem.out problem.out.all gmon.out 98 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/ipasir/ipasir_cpp.cpp: -------------------------------------------------------------------------------- 1 | #include "ipasir_cpp.h" 2 | 3 | namespace ipasir { 4 | int ipasir_terminate_callback(void* state) { 5 | return static_cast(state)->terminateCallback(); 6 | } 7 | 8 | int ipasir_select_literal_callback(void* state) { 9 | return static_cast(state)->selectLiteralCallback(); 10 | } 11 | 12 | void ipasir_learn_callback(void* state, int* clause) { 13 | static_cast(state)->learnedClauseCallback(clause); 14 | } 15 | 16 | Solver::Solver(): 17 | solver(nullptr), 18 | terminateCallback([]{return 0;}), 19 | selectLiteralCallback([]{return 0;}), 20 | learnedClauseCallback([](int*){return;}) { 21 | 22 | reset(); 23 | } 24 | 25 | Solver::~Solver(){ 26 | ipasir_release(solver); 27 | } 28 | 29 | std::string Solver::signature() { 30 | return ipasir_signature(); 31 | } 32 | 33 | void Solver::add(int lit_or_zero) { 34 | ipasir_add(solver, lit_or_zero); 35 | } 36 | 37 | void Ipasir::addClause(std::vector clause) { 38 | for (int literal: clause) { 39 | this->add(literal); 40 | } 41 | this->add(0); 42 | } 43 | 44 | void Solver::assume(int lit) { 45 | ipasir_assume(solver, lit); 46 | } 47 | 48 | SolveResult Solver::solve() { 49 | return static_cast(ipasir_solve(solver)); 50 | } 51 | 52 | int Solver::val(int lit) { 53 | return ipasir_val (solver, lit); 54 | } 55 | 56 | int Solver::failed (int lit) { 57 | return ipasir_failed(solver, lit); 58 | } 59 | 60 | void Solver::set_terminate (std::function callback) { 61 | terminateCallback = callback; 62 | ipasir_set_terminate(this->solver, this, &ipasir_terminate_callback); 63 | } 64 | 65 | void Solver::set_learn (int max_length, std::function callback) { 66 | learnedClauseCallback = callback; 67 | ipasir_set_learn(this->solver, this, max_length, &ipasir_learn_callback); 68 | } 69 | 70 | void Solver::reset() { 71 | if (solver != nullptr) { 72 | ipasir_release(solver); 73 | } 74 | solver = ipasir_init(); 75 | 76 | set_terminate([]{return 0;}); 77 | set_learn(0,[](int*){return;}); 78 | #ifdef USE_EXTENDED_IPASIR 79 | eipasir_set_select_literal_callback(this->solver, this, &ipasir_select_literal_callback); 80 | #endif 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: CmdLineOutput.h 6 | * 7 | * Copyright (c) 2004, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_CMDLINEOUTPUT_H 24 | #define TCLAP_CMDLINEOUTPUT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace TCLAP { 34 | 35 | class CmdLineInterface; 36 | class ArgException; 37 | 38 | /** 39 | * The interface that any output object must implement. 40 | */ 41 | class CmdLineOutput 42 | { 43 | 44 | public: 45 | 46 | /** 47 | * Virtual destructor. 48 | */ 49 | virtual ~CmdLineOutput() {} 50 | 51 | /** 52 | * Generates some sort of output for the USAGE. 53 | * \param c - The CmdLine object the output is generated for. 54 | */ 55 | virtual void usage(CmdLineInterface& c)=0; 56 | 57 | /** 58 | * Generates some sort of output for the version. 59 | * \param c - The CmdLine object the output is generated for. 60 | */ 61 | virtual void version(CmdLineInterface& c)=0; 62 | 63 | /** 64 | * Generates some sort of output for a failure. 65 | * \param c - The CmdLine object the output is generated for. 66 | * \param e - The ArgException that caused the failure. 67 | */ 68 | virtual void failure( CmdLineInterface& c, 69 | ArgException& e )=0; 70 | 71 | }; 72 | 73 | } //namespace TCLAP 74 | #endif 75 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: HelpVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reverved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | #ifndef TCLAP_HELP_VISITOR_H 23 | #define TCLAP_HELP_VISITOR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor object that calls the usage method of the given CmdLineOutput 33 | * object for the specified CmdLine object. 34 | */ 35 | class HelpVisitor: public Visitor 36 | { 37 | private: 38 | /** 39 | * Prevent accidental copying. 40 | */ 41 | HelpVisitor(const HelpVisitor& rhs); 42 | HelpVisitor& operator=(const HelpVisitor& rhs); 43 | 44 | protected: 45 | 46 | /** 47 | * The CmdLine the output will be generated for. 48 | */ 49 | CmdLineInterface* _cmd; 50 | 51 | /** 52 | * The output object. 53 | */ 54 | CmdLineOutput** _out; 55 | 56 | public: 57 | 58 | /** 59 | * Constructor. 60 | * \param cmd - The CmdLine the output will be generated for. 61 | * \param out - The type of output. 62 | */ 63 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 64 | : Visitor(), _cmd( cmd ), _out( out ) { } 65 | 66 | /** 67 | * Calls the usage method of the CmdLineOutput for the 68 | * specified CmdLine. 69 | */ 70 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 71 | 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Vistor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /sat/lingelingbcj/makefile: -------------------------------------------------------------------------------- 1 | #-----------------------------------------------------------------------# 2 | #- GLOBAL DEFS ---------------------------------------------------------# 3 | #-----------------------------------------------------------------------# 4 | 5 | # Keep this as generic as possible. 6 | 7 | NAME=lingeling 8 | VERSION=bcj 9 | 10 | #-----------------------------------------------------------------------# 11 | # Solver signatures have to be both valid file names and C symbols. 12 | # Since Picosat uses a dash '-' for the package name, we have to 13 | # differentiate between with (directory / package name) and without 14 | # dash (the signature). 15 | 16 | SIG=$(NAME)$(VERSION) 17 | DIR=$(NAME)-$(VERSION) 18 | TARGET=libipasir$(SIG).a 19 | 20 | #-----------------------------------------------------------------------# 21 | 22 | CC=g++ 23 | CFLAGS=-Wall -DNDEBUG -O3 -fPIC 24 | 25 | #-----------------------------------------------------------------------# 26 | #- REQUIRED TOP RULES --------------------------------------------------# 27 | #-----------------------------------------------------------------------# 28 | 29 | all: $(TARGET) 30 | 31 | clean: 32 | rm -rf $(DIR) 33 | rm -f *.o *.a *.tar.gz 34 | 35 | #-----------------------------------------------------------------------# 36 | #- INVISIBLE INTERNAL SUB RULES ----------------------------------------# 37 | #-----------------------------------------------------------------------# 38 | 39 | libipasir$(SIG).a: .FORCE 40 | @# 41 | @# get and extract library 42 | @# 43 | rm -rf $(DIR) rm *.tar.gz 44 | wget "http://fmv.jku.at/lingeling/lingeling-bcj-78ebb86-180517.tar.gz" 45 | tar xvf lingeling-bcj-78ebb86-180517.tar.gz 46 | mv lingeling-bcj-78ebb86-180517 $(DIR) 47 | @# 48 | @# configure and build library 49 | @# 50 | cd $(DIR); ./configure.sh -fPIC 51 | make liblgl.a -C $(DIR) 52 | @# 53 | @# compile glue code 54 | @# 55 | make ipasir$(NAME)glue.o 56 | @# 57 | @# merge library and glue code into target 58 | @# 59 | cp $(DIR)/liblgl.a $(TARGET) 60 | ar r $(TARGET) ipasir$(NAME)glue.o 61 | 62 | #-----------------------------------------------------------------------# 63 | #- LOCAL GLUE RULES ----------------------------------------------------# 64 | #-----------------------------------------------------------------------# 65 | 66 | ipasir$(NAME)glue.o: ipasir$(NAME)glue.cpp ipasir.h makefile 67 | $(CC) $(CFLAGS) \ 68 | -DVERSION=\"$(VERSION)\" \ 69 | -I$(DIR) -c ipasir$(NAME)glue.cpp 70 | 71 | #-----------------------------------------------------------------------# 72 | 73 | .FORCE: 74 | .PHONY: all clean 75 | -------------------------------------------------------------------------------- /app/ipasir-check-conflict/ipasir-check-conflict.cc: -------------------------------------------------------------------------------- 1 | // Norbert Manthey, 2017 2 | 3 | // make sure we use IPASIR 4 | #define HAVE_IPASIR 5 | 6 | // declare IPASIR functions here, which we might need 7 | #include "SATSolver.h" 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | inline double cpuTime(void) 20 | { 21 | struct rusage ru; 22 | getrusage(RUSAGE_SELF, &ru); 23 | return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; 24 | } 25 | 26 | void learnhook(void * state, int * clause) { 27 | if(!clause) return; 28 | int len = 0; 29 | while( clause[len] != 0 ) ++len; 30 | std::cout << "c learned clause of size " << len << std::endl; 31 | } 32 | 33 | 34 | int main(int argc, char* argv[]) 35 | { 36 | std::cout << "Norbert Manthey -- IPASIR conflict checker" << std::endl; 37 | std::cout << " reserve max len for conflict of size X and try force a conflict clause of size Y" << std::endl 38 | << " and a full stack of assumption literals" << std::endl; 39 | if(argc < 3) { 40 | std::cout << "usage: " << argv[0] << " X Y ... with 0 < X < Y < 2^30" << std::endl; 41 | return 1; 42 | } 43 | int X = atoi(argv[1]); 44 | int Y = atoi(argv[2]); 45 | if(X<1) { 46 | std::cout << "error: given first number " << X << " is not in limits" << std::endl; 47 | return 1; 48 | } 49 | if(Y<1) { 50 | std::cout << "error: given second number " << Y << " is not in limits" << std::endl; 51 | return 1; 52 | } 53 | 54 | vector assumptions; 55 | vector positive, negative; 56 | 57 | std::vector model; 58 | std::vector conflict; 59 | 60 | SATSolver solver; 61 | solver.addLearnStatHook(X, learnhook); 62 | 63 | double runtime = cpuTime(); 64 | for(int i = 1; i < Y; ++ i) 65 | { 66 | assumptions.push_back(-i); 67 | positive.push_back(i); 68 | negative.push_back(i); 69 | } 70 | positive.push_back(Y); 71 | negative.push_back(-Y); 72 | 73 | solver.addClause(positive); 74 | std::cout << "add clause " << positive << std::endl; 75 | solver.addClause(negative); 76 | std::cout << "add clause " << negative << std::endl; 77 | 78 | std::cout << "solve with assumptions " << assumptions << std::endl; 79 | int ret = solver.solve(assumptions, model, conflict); 80 | if(ret!=20) { 81 | std::cout << "error: solver fails learning a huge clause with status " << ret << std::endl; 82 | return 1; 83 | } 84 | 85 | return 0; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /app/icnf/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'icnf' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= gcc 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | LIBS += -lm 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CC) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o 50 | 51 | #--------------------------------------------------------------------------# 52 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 53 | # is using C++ you might want to explicitly set (and comment out) 54 | # 55 | # LINK=g++ 56 | # 57 | # or something similar. 58 | 59 | icnf: icnf.o $(DEPS) 60 | ${LINK} -o $@ icnf.o $(LIBS) 61 | 62 | #--------------------------------------------------------------------------# 63 | # Local app specific rules. 64 | #--------------------------------------------------------------------------# 65 | 66 | icnf.o: icnf.c ipasir.h makefile 67 | $(CC) $(CFLAGS) -c icnf.c 68 | -------------------------------------------------------------------------------- /app/genipalsp/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | 30 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 31 | then \ 32 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 33 | else \ 34 | echo $(CC) $(CFLAGS); \ 35 | fi) 36 | 37 | #--------------------------------------------------------------------------# 38 | # Here comes the real makefile part which needs to be adapted and provide 39 | # both an 'all' and a 'clean' target. In essence you need to provide 40 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 41 | #--------------------------------------------------------------------------# 42 | 43 | # This part is still generic and the specific part comes further down. 44 | 45 | all: $(TARGET) 46 | 47 | clean: 48 | rm -f $(TARGET) *.o 49 | 50 | #--------------------------------------------------------------------------# 51 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 52 | # is using C++ you might want to explicitly set (and comment out) 53 | # 54 | LINK=g++ 55 | # 56 | # or something similar. 57 | 58 | genipalsp: genipalsp.o $(DEPS) 59 | ${LINK} -o $@ genipalsp.o $(LIBS) 60 | 61 | #--------------------------------------------------------------------------# 62 | # Local app specific rules. 63 | #--------------------------------------------------------------------------# 64 | 65 | genipalsp.o: genipalsp.cpp ipasir.h makefile 66 | $(CC) $(CFLAGS) -c genipalsp.cpp 67 | -------------------------------------------------------------------------------- /sat/README: -------------------------------------------------------------------------------- 1 | Each subdirectory corresponds to a SAT solver back end with a specific 2 | version. Multiple versions of the same solver need separate top level 3 | directories here. 4 | 5 | To explain the structure consider the 6 | 7 | picosat961 8 | 9 | directory which at the same time is also the specific signature name 10 | of this solver. This directory name has to match the string 11 | returned by the 'ipasir_signature' function. We also expect that the name 12 | is both a legal file name and a legal C symbol name. In particular it 13 | should not contain white space nor punctuation characters.Please use 14 | underscores '_' if needed. Thus you can not have a space ' ', a dash '-', 15 | nor dot '.' as signature name or directory name. 16 | 17 | Each solver has its own package in the solver directory, like 18 | 19 | picosat961/picosat-961.tar.gz 20 | 21 | This is supposed to be the standard distribution package for the solver, 22 | e.g., as available for download on the web. Further there has to be a 23 | 'makefile' (lower case), e.g., 24 | 25 | picosat961/makefile 26 | 27 | Its default goal should extract the package, build the library, compile 28 | additional glue code and to include everything into one library, e.g., 29 | 'picosat961/libipasirpicosat961.a'. Compiling the glue code and optionally 30 | merging it with the original library code is the responsibility of the 31 | 'makefile' too. 32 | 33 | For 'picosat961' we include a simple separate glue code defined in 34 | 'picosat961/ipasirpicosatglue.c' which is compiled and added to the 35 | archive of the original library and then gives the main target 36 | 37 | picosat961/libipasirpicosat961.a 38 | 39 | These target libraries thus have the generic name 40 | 41 | /libipasir.a 42 | 43 | You can assume that the 'ipasir.h' header file is in the top level 44 | directory, e.g., available as '../../ipasir.h' from the solver directory. 45 | 46 | To prepare a submission to the competition go to the 'ipasir/sat' 47 | directory and zip your solver, e.g., 48 | 49 | ipasir/sat$ tar zcf ipasirpicosat961.tar.gz picosat961/ 50 | 51 | This should contain the 'makefile' and all required library and glue code 52 | for producing the target library, and optionally two specific files for 53 | linking. The first one '/LINK' is used to specify the 54 | required link command, e.g., 'gcc' or 'g++', and the second file 55 | '/LIBS' contains additional system libraries, e.g., '-lz', 56 | '-lm', or even '-lstdc++', if necessary. If the first file does not exist 57 | or is empty 'cc' is used for linking (which on Ubuntu for instance defaults 58 | to 'gcc'). If the second file is empty or does not exist then no additional 59 | libraries are needed. 60 | 61 | Armin Biere 62 | Don Jan 29 15:37:49 CET 2015 63 | -------------------------------------------------------------------------------- /app/genipabones/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC = g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | 30 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 31 | then \ 32 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 33 | else \ 34 | echo $(CC) $(CFLAGS); \ 35 | fi) 36 | 37 | #--------------------------------------------------------------------------# 38 | # Here comes the real makefile part which needs to be adapted and provide 39 | # both an 'all' and a 'clean' target. In essence you need to provide 40 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 41 | #--------------------------------------------------------------------------# 42 | 43 | # This part is still generic and the specific part comes further down. 44 | 45 | all: $(TARGET) 46 | 47 | clean: 48 | rm -f $(TARGET) *.o 49 | 50 | #--------------------------------------------------------------------------# 51 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 52 | # is using C++ you might want to explicitly set (and comment out) 53 | # 54 | LINK=g++ 55 | # 56 | # or something similar. 57 | 58 | genipabones: genipabones.o $(DEPS) 59 | ${LINK} -o $@ genipabones.o $(LIBS) 60 | 61 | #--------------------------------------------------------------------------# 62 | # Local app specific rules. 63 | #--------------------------------------------------------------------------# 64 | 65 | genipabones.o: genipabones.cpp ipasir.h makefile 66 | $(CC) $(CFLAGS) -c genipabones.cpp 67 | -------------------------------------------------------------------------------- /app/genipasat/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= gcc 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | LIBS += -lm 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CC) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o 50 | 51 | #--------------------------------------------------------------------------# 52 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 53 | # is using C++ you might want to explicitly set (and comment out) 54 | # 55 | # LINK=g++ 56 | # 57 | # or something similar. 58 | 59 | genipasat: genipasat.o $(DEPS) 60 | ${LINK} -o $@ genipasat.o $(LIBS) 61 | 62 | #--------------------------------------------------------------------------# 63 | # Local app specific rules. 64 | #--------------------------------------------------------------------------# 65 | 66 | genipasat.o: genipasat.c ipasir.h makefile 67 | $(CC) $(CFLAGS) -c genipasat.c 68 | -------------------------------------------------------------------------------- /app/genipareach/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC = g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O0 -g 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | 30 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 31 | then \ 32 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 33 | else \ 34 | echo $(CC) $(CFLAGS); \ 35 | fi) 36 | 37 | #--------------------------------------------------------------------------# 38 | # Here comes the real makefile part which needs to be adapted and provide 39 | # both an 'all' and a 'clean' target. In essence you need to provide 40 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 41 | #--------------------------------------------------------------------------# 42 | 43 | # This part is still generic and the specific part comes further down. 44 | 45 | all: $(TARGET) 46 | 47 | clean: 48 | rm -f $(TARGET) *.o 49 | 50 | #--------------------------------------------------------------------------# 51 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 52 | # is using C++ you might want to explicitly set (and comment out) 53 | # 54 | LINK=g++ 55 | # 56 | # or something similar. 57 | 58 | genipareach: genipareach.o $(DEPS) 59 | ${LINK} -o $@ genipareach.o $(LIBS) 60 | 61 | #--------------------------------------------------------------------------# 62 | # Local app specific rules. 63 | #--------------------------------------------------------------------------# 64 | 65 | genipareach.o: genipareach.cpp ipasir.h makefile 66 | $(CC) $(CFLAGS) -c genipareach.cpp 67 | -------------------------------------------------------------------------------- /app/genipafolio/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) -lpthread 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | 30 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 31 | then \ 32 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 33 | else \ 34 | echo $(CC) $(CFLAGS); \ 35 | fi) 36 | 37 | #--------------------------------------------------------------------------# 38 | # Here comes the real makefile part which needs to be adapted and provide 39 | # both an 'all' and a 'clean' target. In essence you need to provide 40 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 41 | #--------------------------------------------------------------------------# 42 | 43 | # This part is still generic and the specific part comes further down. 44 | 45 | all: $(TARGET) 46 | 47 | clean: 48 | rm -f $(TARGET) *.o 49 | 50 | #--------------------------------------------------------------------------# 51 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 52 | # is using C++ you might want to explicitly set (and comment out) 53 | # 54 | LINK=g++ 55 | # 56 | # or something similar. 57 | 58 | genipafolio: genipafolio.o $(DEPS) 59 | ${LINK} -o $@ genipafolio.o $(LIBS) 60 | 61 | #--------------------------------------------------------------------------# 62 | # Local app specific rules. 63 | #--------------------------------------------------------------------------# 64 | 65 | genipafolio.o: genipafolio.cpp ipasir.h makefile 66 | $(CC) $(CFLAGS) -c genipafolio.cpp 67 | -------------------------------------------------------------------------------- /app/ipasir-check-satunsat/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= gcc 23 | CXX ?= g++ 24 | CFLAGS ?= -Wall -DNDEBUG -O3 25 | 26 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 27 | 28 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 29 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CXX) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o *~ 50 | 51 | #--------------------------------------------------------------------------# 52 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 53 | # is using C++ you might want to explicitly set (and comment out) 54 | # 55 | # LINK=g++ 56 | # 57 | # or something similar. 58 | 59 | $(TARGET): $(TARGET).o $(DEPS) 60 | ${LINK} -o $@ $(TARGET).o $(LIBS) 61 | 62 | #--------------------------------------------------------------------------# 63 | # Local app specific rules. 64 | #--------------------------------------------------------------------------# 65 | 66 | $(TARGET).o: $(TARGET).cc ipasir.h makefile 67 | $(CXX) $(CFLAGS) -c $(TARGET).cc 68 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= gcc 23 | CXX ?= g++ 24 | CFLAGS ?= -Wall -DNDEBUG -O3 25 | 26 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 27 | 28 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 29 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CXX) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o *~ 50 | 51 | #--------------------------------------------------------------------------# 52 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 53 | # is using C++ you might want to explicitly set (and comment out) 54 | # 55 | # LINK=g++ 56 | # 57 | # or something similar. 58 | 59 | $(TARGET): $(TARGET).o $(DEPS) 60 | ${LINK} -o $@ $(TARGET).o $(LIBS) 61 | 62 | #--------------------------------------------------------------------------# 63 | # Local app specific rules. 64 | #--------------------------------------------------------------------------# 65 | 66 | $(TARGET).o: $(TARGET).cc ipasir.h makefile 67 | $(CXX) $(CFLAGS) -c $(TARGET).cc 68 | -------------------------------------------------------------------------------- /app/ipasir-check-conflict/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= gcc 23 | CXX ?= g++ 24 | CFLAGS ?= -Wall -DNDEBUG -O3 25 | 26 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 27 | 28 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 29 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CXX) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o *~ 50 | 51 | 52 | #--------------------------------------------------------------------------# 53 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 54 | # is using C++ you might want to explicitly set (and comment out) 55 | # 56 | # LINK=g++ 57 | # 58 | # or something similar. 59 | 60 | $(TARGET): $(TARGET).o $(DEPS) 61 | ${LINK} -o $@ $(TARGET).o $(LIBS) 62 | 63 | #--------------------------------------------------------------------------# 64 | # Local app specific rules. 65 | #--------------------------------------------------------------------------# 66 | 67 | $(TARGET).o: $(TARGET).cc ipasir.h makefile 68 | $(CXX) $(CFLAGS) -c $(TARGET).cc 69 | -------------------------------------------------------------------------------- /app/genipaessentials/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC ?= g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O3 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 29 | 30 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 31 | then \ 32 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 33 | else \ 34 | echo $(CC) $(CFLAGS); \ 35 | fi) 36 | 37 | #--------------------------------------------------------------------------# 38 | # Here comes the real makefile part which needs to be adapted and provide 39 | # both an 'all' and a 'clean' target. In essence you need to provide 40 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 41 | #--------------------------------------------------------------------------# 42 | 43 | # This part is still generic and the specific part comes further down. 44 | 45 | all: $(TARGET) 46 | 47 | clean: 48 | rm -f $(TARGET) *.o 49 | 50 | #--------------------------------------------------------------------------# 51 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 52 | # is using C++ you might want to explicitly set (and comment out) 53 | # 54 | LINK=g++ 55 | # 56 | # or something similar. 57 | 58 | genipaessentials: genipaessentials.o $(DEPS) 59 | ${LINK} -o $@ genipaessentials.o $(LIBS) 60 | 61 | #--------------------------------------------------------------------------# 62 | # Local app specific rules. 63 | #--------------------------------------------------------------------------# 64 | 65 | genipaessentials.o: genipaessentials.cpp ipasir.h makefile 66 | $(CC) $(CFLAGS) -c genipaessentials.cpp 67 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/unit_tests/TestTimePointBasedSolver.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "gmock/gmock.h" 3 | #include "ipasir/test/mock_ipasir_cpp.h" 4 | #include "TimePointBasedSolver.h" 5 | #include "TimeSlotMapping.h" 6 | 7 | using ::testing::_; 8 | using ::testing::InSequence; 9 | 10 | class TimePointBasedSolver_mini : public ::testing::Test { 11 | public: 12 | TimePointBasedSolver_mini() { 13 | SingleEndedTimePointManager tpm; 14 | t0 = tpm.aquireNext(); 15 | t1 = tpm.aquireNext(); 16 | 17 | std::unique_ptr ipasirPtr = 18 | std::make_unique(); 19 | ipasir = ipasirPtr.get(); 20 | 21 | int varsPerTime = 2; 22 | int helperPerTime = 1; 23 | solver = std::make_unique(varsPerTime, 24 | helperPerTime, std::move(ipasirPtr)); 25 | } 26 | 27 | TimePoint t0; 28 | TimePoint t1; 29 | 30 | std::unique_ptr solver; 31 | ipasir::MockIpasir* ipasir; 32 | }; 33 | 34 | TEST_F( TimePointBasedSolver_mini, addPositive) { 35 | InSequence dummy; 36 | 37 | EXPECT_CALL(*ipasir, add(1)); 38 | EXPECT_CALL(*ipasir, add(4)); 39 | 40 | solver->addProblemLiteral(1, t0); 41 | solver->addProblemLiteral(1, t1); 42 | } 43 | 44 | TEST_F( TimePointBasedSolver_mini, addNegative) { 45 | InSequence dummy; 46 | 47 | EXPECT_CALL(*ipasir, add(-1)); 48 | EXPECT_CALL(*ipasir, add(-4)); 49 | 50 | solver->addProblemLiteral(-1, t0); 51 | solver->addProblemLiteral(-1, t1); 52 | } 53 | 54 | TEST_F( TimePointBasedSolver_mini, addPositiveHelper) { 55 | InSequence dummy; 56 | 57 | EXPECT_CALL(*ipasir, add(3)); 58 | EXPECT_CALL(*ipasir, add(6)); 59 | 60 | solver->addHelperLiteral(1, t0); 61 | solver->addHelperLiteral(1, t1); 62 | } 63 | 64 | TEST_F( TimePointBasedSolver_mini, addNegativeHelper) { 65 | InSequence dummy; 66 | 67 | EXPECT_CALL(*ipasir, add(-3)); 68 | EXPECT_CALL(*ipasir, add(-6)); 69 | 70 | solver->addHelperLiteral(-1, t0); 71 | solver->addHelperLiteral(-1, t1); 72 | } 73 | 74 | TEST_F( TimePointBasedSolver_mini, inteferences) { 75 | InSequence dummy; 76 | EXPECT_CALL(*ipasir, add(1)) 77 | .Times(2); 78 | EXPECT_CALL(*ipasir, add(2)) 79 | .Times(1); 80 | EXPECT_CALL(*ipasir, add(3)) 81 | .Times(1); 82 | 83 | EXPECT_CALL(*ipasir, add(4)) 84 | .Times(2); 85 | EXPECT_CALL(*ipasir, add(-5)) 86 | .Times(1); 87 | EXPECT_CALL(*ipasir, add(-6)) 88 | .Times(1); 89 | 90 | EXPECT_CALL(*ipasir, add(1)) 91 | .Times(1); 92 | 93 | solver->addProblemLiteral(1, t0); 94 | solver->addProblemLiteral(1, t0); 95 | solver->addProblemLiteral(2, t0); 96 | solver->addHelperLiteral(1, t0); 97 | 98 | solver->addProblemLiteral(1, t1); 99 | solver->addProblemLiteral(1, t1); 100 | solver->addProblemLiteral(-2, t1); 101 | solver->addHelperLiteral(-1, t1); 102 | 103 | solver->addProblemLiteral(1, t0); 104 | } -------------------------------------------------------------------------------- /app/genipamax/makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------# 2 | # The target name should be the name of this app, which actually should be 3 | # the same as the name of this directory, e.g., 'genipasat' etc. 4 | #--------------------------------------------------------------------------# 5 | 6 | TARGET=$(shell basename "`pwd`") 7 | 8 | #--------------------------------------------------------------------------# 9 | # When called from the 'mkone.sh' script the 'IPASIRSOLVER' variable will be 10 | # overwritten. For testing purposes we simply set it to the default PicoSAT 11 | # front-end (currently 'picosat960'). This allows to call 'make' in this 12 | # directory without the need to specify the 'IPASIRSOLVER' variable. 13 | #--------------------------------------------------------------------------# 14 | 15 | IPASIRSOLVER ?= picosat961 16 | 17 | #--------------------------------------------------------------------------# 18 | # There is usually no need to change something here unless you want to force 19 | # a specific compiler or specific compile flags. 20 | #--------------------------------------------------------------------------# 21 | 22 | CC = g++ 23 | CFLAGS ?= -Wall -DNDEBUG -O3 -std=c++0x 24 | 25 | DEPS = ../../sat/$(IPASIRSOLVER)/libipasir$(IPASIRSOLVER).a 26 | 27 | LIBS = -L../../sat/$(IPASIRSOLVER)/ -lipasir$(IPASIRSOLVER) 28 | LIBS += -Lpblib -lpblib 29 | LIBS += $(shell cat ../../sat/$(IPASIRSOLVER)/LIBS 2>/dev/null) 30 | 31 | LINK = $(shell if [ -f ../../sat/$(IPASIRSOLVER)/LINK ]; \ 32 | then \ 33 | cat ../../sat/$(IPASIRSOLVER)/LINK; \ 34 | else \ 35 | echo $(CC) $(CFLAGS); \ 36 | fi) 37 | 38 | #--------------------------------------------------------------------------# 39 | # Here comes the real makefile part which needs to be adapted and provide 40 | # both an 'all' and a 'clean' target. In essence you need to provide 41 | # linking options, which links your app to a generic 'IPASIRSOLVER'. 42 | #--------------------------------------------------------------------------# 43 | 44 | # This part is still generic and the specific part comes further down. 45 | 46 | all: $(TARGET) 47 | 48 | clean: 49 | rm -f $(TARGET) *.o 50 | rm -rf pblib 51 | 52 | #--------------------------------------------------------------------------# 53 | # Some back-end SAT solvers require C++ linking, e.g., 'g++'. If your app 54 | # is using C++ you might want to explicitly set (and comment out) 55 | # 56 | LINK=$(CC) 57 | # 58 | # or something similar. 59 | 60 | genipamax: genipamax.o $(DEPS) 61 | ${LINK} -o $@ genipamax.o $(LIBS) 62 | 63 | #--------------------------------------------------------------------------# 64 | # Local app specific rules. 65 | #--------------------------------------------------------------------------# 66 | 67 | lib-pblib: 68 | ./buildPblib.sh 69 | 70 | genipamax.o: genipamax.cpp ipasir.h makefile lib-pblib 71 | $(CC) $(CFLAGS) -c genipamax.cpp 72 | -------------------------------------------------------------------------------- /sat/picosat961/makefile: -------------------------------------------------------------------------------- 1 | #-----------------------------------------------------------------------# 2 | #- GLOBAL DEFS ---------------------------------------------------------# 3 | #-----------------------------------------------------------------------# 4 | 5 | # Keep this as generic as possible. 6 | 7 | NAME=picosat 8 | 9 | # Avoid hardcoding the version number in this file. This allows us to just 10 | # drop a new distribution package into this directory without changing 11 | # anything else. For other more complicated set-ups / solvers something like 12 | # 'VERSION=961' should also work, if you have the appropriate tar file 13 | # available, e.g., 'picosat-961.tar.gz', which extracts into 'picosat-961'. 14 | 15 | # NOTE: requires GNU make extension '$(shell ...)'. 16 | 17 | VERSION=$(shell ls $(NAME)-*.tar.gz | tail -1 | \ 18 | sed -e 's,$(NAME)-,,' -e 's,.tar.gz,,') 19 | 20 | #-----------------------------------------------------------------------# 21 | # Solver signatures have to be both valid file names and C symbols. 22 | # Since Picosat uses a dash '-' for the package name, we have to 23 | # differentiate between with (directory / package name) and without 24 | # dash (the signature). 25 | 26 | SIG=$(NAME)$(VERSION) 27 | DIR=$(NAME)-$(VERSION) 28 | TARGET=libipasir$(SIG).a 29 | 30 | #-----------------------------------------------------------------------# 31 | 32 | CC=gcc 33 | CFLAGS=-Wall -DNDEBUG -O3 -fPIC 34 | 35 | #-----------------------------------------------------------------------# 36 | #- REQUIRED TOP RULES --------------------------------------------------# 37 | #-----------------------------------------------------------------------# 38 | 39 | all: $(TARGET) 40 | 41 | clean: 42 | rm -rf $(DIR) 43 | rm -f *.o *.a 44 | 45 | #-----------------------------------------------------------------------# 46 | #- INVISIBLE INTERNAL SUB RULES ----------------------------------------# 47 | #-----------------------------------------------------------------------# 48 | 49 | libipasir$(SIG).a: .FORCE 50 | @# 51 | @# extract library 52 | @# 53 | rm -rf $(DIR) 54 | tar xvf $(DIR).tar.gz 55 | @# 56 | @# configure and build library 57 | @# 58 | cd $(DIR); ./configure -O --no-trace --shared 59 | make -C $(DIR) 60 | @# 61 | @# compile glue code 62 | @# 63 | make ipasir$(NAME)glue.o 64 | @# 65 | @# merge library and glue code into target 66 | @# 67 | cp $(DIR)/lib$(NAME).a $(TARGET) 68 | ar r $(TARGET) ipasir$(NAME)glue.o 69 | 70 | #-----------------------------------------------------------------------# 71 | #- LOCAL GLUE RULES ----------------------------------------------------# 72 | #-----------------------------------------------------------------------# 73 | 74 | ipasir$(NAME)glue.o: ipasir$(NAME)glue.c ipasir.h makefile 75 | $(CC) $(CFLAGS) \ 76 | -DVERSION=\"$(VERSION)\" \ 77 | -I$(DIR) -c ipasir$(NAME)glue.c 78 | 79 | #-----------------------------------------------------------------------# 80 | 81 | .FORCE: 82 | .PHONY: all clean 83 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | // This is an internal tclap file, you should probably not have to 24 | // include this directly 25 | 26 | #ifndef TCLAP_ARGTRAITS_H 27 | #define TCLAP_ARGTRAITS_H 28 | 29 | namespace TCLAP { 30 | 31 | // We use two empty structs to get compile type specialization 32 | // function to work 33 | 34 | /** 35 | * A value like argument value type is a value that can be set using 36 | * operator>>. This is the default value type. 37 | */ 38 | struct ValueLike { 39 | typedef ValueLike ValueCategory; 40 | virtual ~ValueLike() {} 41 | }; 42 | 43 | /** 44 | * A string like argument value type is a value that can be set using 45 | * operator=(string). Usefull if the value type contains spaces which 46 | * will be broken up into individual tokens by operator>>. 47 | */ 48 | struct StringLike { 49 | virtual ~StringLike() {} 50 | }; 51 | 52 | /** 53 | * A class can inherit from this object to make it have string like 54 | * traits. This is a compile time thing and does not add any overhead 55 | * to the inherenting class. 56 | */ 57 | struct StringLikeTrait { 58 | typedef StringLike ValueCategory; 59 | virtual ~StringLikeTrait() {} 60 | }; 61 | 62 | /** 63 | * A class can inherit from this object to make it have value like 64 | * traits. This is a compile time thing and does not add any overhead 65 | * to the inherenting class. 66 | */ 67 | struct ValueLikeTrait { 68 | typedef ValueLike ValueCategory; 69 | virtual ~ValueLikeTrait() {} 70 | }; 71 | 72 | /** 73 | * Arg traits are used to get compile type specialization when parsing 74 | * argument values. Using an ArgTraits you can specify the way that 75 | * values gets assigned to any particular type during parsing. The two 76 | * supported types are StringLike and ValueLike. 77 | */ 78 | template 79 | struct ArgTraits { 80 | typedef typename T::ValueCategory ValueCategory; 81 | virtual ~ArgTraits() {} 82 | //typedef ValueLike ValueCategory; 83 | }; 84 | 85 | #endif 86 | 87 | } // namespace 88 | -------------------------------------------------------------------------------- /sat/minisat220/makefile: -------------------------------------------------------------------------------- 1 | #-----------------------------------------------------------------------# 2 | #- GLOBAL DEFS ---------------------------------------------------------# 3 | #-----------------------------------------------------------------------# 4 | 5 | # Keep this as generic as possible. 6 | 7 | NAME=minisat 8 | 9 | # Avoid hardcoding the version number in this file. This allows us to just 10 | # drop a new distribution package into this directory without changing 11 | # anything else. For other more complicated set-ups / solvers something like 12 | # 'VERSION=960' should also work, if you have the appropriate tar file 13 | # available, e.g., 'picosat-960.tar.gz', which extracts into 'picosat-960'. 14 | 15 | # NOTE: requires GNU make extension '$(shell ...)'. 16 | 17 | VERSION=$(shell ls $(NAME)-*.tar.gz | tail -1 | \ 18 | sed -e 's,$(NAME)-,,' -e 's,.tar.gz,,') 19 | 20 | #-----------------------------------------------------------------------# 21 | # Solver signatures have to be both valid file names and C symbols. 22 | # Since Picosat uses a dash '-' for the package name, we have to 23 | # differentiate between with (directory / package name) and without 24 | # dash (the signature). 25 | 26 | SIG=$(NAME)$(VERSION) 27 | DIR=$(NAME)-$(VERSION) 28 | TARGET=libipasir$(SIG).a 29 | 30 | #-----------------------------------------------------------------------# 31 | 32 | CXX=g++ 33 | CXXFLAGS=-Wall -DNDEBUG -O3 -fPIC 34 | 35 | #-----------------------------------------------------------------------# 36 | #- REQUIRED TOP RULES --------------------------------------------------# 37 | #-----------------------------------------------------------------------# 38 | 39 | all: $(TARGET) 40 | 41 | clean: 42 | rm -rf $(DIR) 43 | rm -f *.o *.a 44 | 45 | #-----------------------------------------------------------------------# 46 | #- INVISIBLE INTERNAL SUB RULES ----------------------------------------# 47 | #-----------------------------------------------------------------------# 48 | 49 | libipasir$(SIG).a: .FORCE 50 | @# 51 | @# extract library 52 | @# 53 | rm -rf $(DIR) 54 | tar xvf $(DIR).tar.gz 55 | @# 56 | @# apply patch for set_terminate and learn_callback 57 | @# 58 | patch minisat-220/minisat/core/Solver.cc < minisat-cc.patch 59 | patch minisat-220/minisat/core/Solver.h < minisat-h.patch 60 | @# 61 | @# patch verbose output 62 | @# 63 | sed -i -e 's,"\([=|]\),"c [${SIG}] \1,' $(DIR)/minisat/core/Main.cc 64 | sed -i -e 's,"\([=|]\),"c [${SIG}] \1,' $(DIR)/minisat/core/Solver.cc 65 | @# 66 | @# configure and build library 67 | @# 68 | make -C $(DIR) config 69 | patch minisat-220/config.mk < minisat-config.patch 70 | make -C $(DIR) lr 71 | @# 72 | @# compile glue code 73 | @# 74 | make ipasir$(NAME)glue.o 75 | @# 76 | @# merge library and glue code into target 77 | @# 78 | cp $(DIR)/build/release/lib/lib$(NAME).a $(TARGET) 79 | ar r $(TARGET) ipasir$(NAME)glue.o 80 | 81 | #-----------------------------------------------------------------------# 82 | #- LOCAL GLUE RULES ----------------------------------------------------# 83 | #-----------------------------------------------------------------------# 84 | 85 | ipasir$(NAME)glue.o: ipasir$(NAME)glue.cc ipasir.h makefile 86 | $(CXX) $(CXXFLAGS) \ 87 | -DVERSION=\"$(VERSION)\" \ 88 | -I$(DIR) -I$(DIR)/minisat/core -c ipasir$(NAME)glue.cc 89 | 90 | #-----------------------------------------------------------------------# 91 | 92 | .FORCE: 93 | .PHONY: all clean 94 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/unit_tests/TestTimeSlotMapping.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "TimeSlotMapping.h" 3 | 4 | #include 5 | 6 | TEST( SingleEndedTimePointManager, basic) { 7 | SingleEndedTimePointManager tpm; 8 | 9 | auto t0 = tpm.aquireNext(); 10 | ASSERT_TRUE( tpm.getFirst() == t0 ); 11 | ASSERT_TRUE( tpm.getLast() == t0 ); 12 | 13 | auto t1 = tpm.aquireNext(); 14 | ASSERT_TRUE( tpm.getFirst() == t0 ); 15 | ASSERT_TRUE( tpm.getLast() == t1 ); 16 | ASSERT_TRUE( tpm.getPredecessor(t1) == t0 ); 17 | ASSERT_TRUE( tpm.getSuccessor(t0) == t1 ); 18 | 19 | auto t2 = tpm.aquireNext(); 20 | ASSERT_TRUE( tpm.getFirst() == t0 ); 21 | ASSERT_TRUE( tpm.getLast() == t2 ); 22 | ASSERT_TRUE( tpm.getPredecessor(t1) == t0 ); 23 | ASSERT_TRUE( tpm.getSuccessor(t1) == t2 ); 24 | } 25 | 26 | TEST( SingleEndedTimePointManager, traversal) { 27 | SingleEndedTimePointManager tpm; 28 | 29 | auto t0 = tpm.aquireNext(); 30 | auto t1 = tpm.aquireNext(); 31 | auto t2 = tpm.aquireNext(); 32 | 33 | auto t = tpm.getFirst(); 34 | ASSERT_TRUE( t == t0 ); 35 | t = tpm.getSuccessor(t); 36 | ASSERT_TRUE( t == t1 ); 37 | t = tpm.getSuccessor(t); 38 | ASSERT_TRUE( t == t2 ); 39 | ASSERT_TRUE( t == tpm.getLast() ); 40 | } 41 | 42 | TEST( DoubleEndedTimePointManager, allBegin_unique) { 43 | DoubleEndedTimePointManager tpm(1.f, 44 | DoubleEndedTimePointManager::TopElementOption::Unique); 45 | 46 | auto t0 = tpm.aquireNext(); 47 | auto tn = tpm.aquireNext(); 48 | 49 | ASSERT_TRUE( tpm.getFirst() == t0 ); 50 | ASSERT_TRUE( tpm.getLast() == tn ); 51 | 52 | TimePoint previous = t0; 53 | for (int i = 0; i < 20; i++) { 54 | auto t = tpm.aquireNext(); 55 | ASSERT_TRUE( tpm.isOnForwardStack(t) ); 56 | ASSERT_TRUE( tpm.getFirst() == t0 ); 57 | ASSERT_TRUE( tpm.getLast() == tn ); 58 | ASSERT_TRUE( tpm.getPredecessor(t) == previous ); 59 | ASSERT_TRUE( tpm.getSuccessor(t) == tn ); 60 | previous = t; 61 | } 62 | } 63 | 64 | TEST( DoubleEndedTimePointManager, allBegin_dublicate) { 65 | DoubleEndedTimePointManager tpm(1.f, 66 | DoubleEndedTimePointManager::TopElementOption::Dublicated); 67 | 68 | auto t0 = tpm.aquireNext(); 69 | auto tn = tpm.aquireNext(); 70 | 71 | ASSERT_TRUE( tpm.getFirst() == t0 ); 72 | ASSERT_TRUE( tpm.getLast() == tn ); 73 | 74 | TimePoint previous = t0; 75 | for (int i = 0; i < 20; i++) { 76 | auto t = tpm.aquireNext(); 77 | ASSERT_TRUE( tpm.isOnForwardStack(t) ); 78 | ASSERT_TRUE( tpm.getFirst() == t0 ); 79 | ASSERT_TRUE( tpm.getLast() == tn ); 80 | ASSERT_TRUE( tpm.getPredecessor(t) == previous ); 81 | ASSERT_TRUE( tpm.getSuccessor(previous) == tn ); 82 | try { 83 | tpm.getSuccessor(t); 84 | FAIL() << ""; 85 | } catch (std::out_of_range const & err) { 86 | 87 | } catch (...) { 88 | FAIL() << "Wrong Exception"; 89 | } 90 | previous = t; 91 | } 92 | } 93 | 94 | TEST( DoubleEndedTimePointManager, r05_dublicate) { 95 | DoubleEndedTimePointManager tpm(0.5f, 96 | DoubleEndedTimePointManager::TopElementOption::Dublicated); 97 | 98 | auto t0 = tpm.aquireNext(); 99 | auto tn = tpm.aquireNext(); 100 | 101 | ASSERT_TRUE( tpm.getFirst() == t0 ); 102 | ASSERT_TRUE( tpm.getLast() == tn ); 103 | 104 | bool putForward = true; 105 | for (int i = 0; i < 20; i++) { 106 | auto t = tpm.aquireNext(); 107 | if (putForward) { 108 | ASSERT_TRUE( tpm.isOnForwardStack(t) ); 109 | } else { 110 | ASSERT_FALSE( tpm.isOnForwardStack(t) ); 111 | } 112 | putForward ^= true; 113 | 114 | TimePoint forward = tpm.getFirst(); 115 | TimePoint backward = tpm.getLast(); 116 | for (int j = 0; j <= i; j ++) { 117 | forward = tpm.getSuccessor(forward); 118 | backward = tpm.getPredecessor(backward); 119 | } 120 | ASSERT_TRUE(forward == tn); 121 | ASSERT_TRUE(backward == t0); 122 | } 123 | } -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/ValuesConstraint.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ValuesConstraint.h 6 | * 7 | * Copyright (c) 2005, Michael E. Smoot 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_VALUESCONSTRAINT_H 24 | #define TCLAP_VALUESCONSTRAINT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include 32 | #else 33 | #define HAVE_SSTREAM 34 | #endif 35 | 36 | #if defined(HAVE_SSTREAM) 37 | #include 38 | #elif defined(HAVE_STRSTREAM) 39 | #include 40 | #else 41 | #error "Need a stringstream (sstream or strstream) to compile!" 42 | #endif 43 | 44 | namespace TCLAP { 45 | 46 | /** 47 | * A Constraint that constrains the Arg to only those values specified 48 | * in the constraint. 49 | */ 50 | template 51 | class ValuesConstraint : public Constraint 52 | { 53 | 54 | public: 55 | 56 | /** 57 | * Constructor. 58 | * \param allowed - vector of allowed values. 59 | */ 60 | ValuesConstraint(std::vector& allowed); 61 | 62 | /** 63 | * Virtual destructor. 64 | */ 65 | virtual ~ValuesConstraint() {} 66 | 67 | /** 68 | * Returns a description of the Constraint. 69 | */ 70 | virtual std::string description() const; 71 | 72 | /** 73 | * Returns the short ID for the Constraint. 74 | */ 75 | virtual std::string shortID() const; 76 | 77 | /** 78 | * The method used to verify that the value parsed from the command 79 | * line meets the constraint. 80 | * \param value - The value that will be checked. 81 | */ 82 | virtual bool check(const T& value) const; 83 | 84 | protected: 85 | 86 | /** 87 | * The list of valid values. 88 | */ 89 | std::vector _allowed; 90 | 91 | /** 92 | * The string used to describe the allowed values of this constraint. 93 | */ 94 | std::string _typeDesc; 95 | 96 | }; 97 | 98 | template 99 | ValuesConstraint::ValuesConstraint(std::vector& allowed) 100 | : _allowed(allowed), 101 | _typeDesc("") 102 | { 103 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 104 | { 105 | 106 | #if defined(HAVE_SSTREAM) 107 | std::ostringstream os; 108 | #elif defined(HAVE_STRSTREAM) 109 | std::ostrstream os; 110 | #else 111 | #error "Need a stringstream (sstream or strstream) to compile!" 112 | #endif 113 | 114 | os << _allowed[i]; 115 | 116 | std::string temp( os.str() ); 117 | 118 | if ( i > 0 ) 119 | _typeDesc += "|"; 120 | _typeDesc += temp; 121 | } 122 | } 123 | 124 | template 125 | bool ValuesConstraint::check( const T& val ) const 126 | { 127 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 128 | return false; 129 | else 130 | return true; 131 | } 132 | 133 | template 134 | std::string ValuesConstraint::shortID() const 135 | { 136 | return _typeDesc; 137 | } 138 | 139 | template 140 | std::string ValuesConstraint::description() const 141 | { 142 | return _typeDesc; 143 | } 144 | 145 | 146 | } //namespace TCLAP 147 | #endif 148 | 149 | -------------------------------------------------------------------------------- /app/genipalsp/inputs/maze-12-0.3-1.grid: -------------------------------------------------------------------------------- 1 | p sp 144 252 2 | a 1 13 1 3 | a 1 2 1 4 | a 2 14 1 5 | a 2 1 1 6 | a 2 3 1 7 | a 3 2 1 8 | a 3 4 1 9 | a 4 16 1 10 | a 4 3 1 11 | a 6 18 1 12 | a 6 7 1 13 | a 7 19 1 14 | a 7 6 1 15 | a 7 8 1 16 | a 8 20 1 17 | a 8 7 1 18 | a 8 9 1 19 | a 9 8 1 20 | a 9 10 1 21 | a 10 22 1 22 | a 10 9 1 23 | a 10 11 1 24 | a 11 23 1 25 | a 11 10 1 26 | a 13 1 1 27 | a 13 14 1 28 | a 14 2 1 29 | a 14 26 1 30 | a 14 13 1 31 | a 16 4 1 32 | a 16 28 1 33 | a 16 17 1 34 | a 17 16 1 35 | a 17 18 1 36 | a 18 6 1 37 | a 18 17 1 38 | a 18 19 1 39 | a 19 7 1 40 | a 19 18 1 41 | a 19 20 1 42 | a 20 8 1 43 | a 20 32 1 44 | a 20 19 1 45 | a 22 10 1 46 | a 22 23 1 47 | a 23 11 1 48 | a 23 22 1 49 | a 23 24 1 50 | a 24 36 1 51 | a 24 23 1 52 | a 26 14 1 53 | a 26 38 1 54 | a 28 16 1 55 | a 28 40 1 56 | a 32 20 1 57 | a 32 44 1 58 | a 32 33 1 59 | a 33 32 1 60 | a 36 24 1 61 | a 36 48 1 62 | a 37 38 1 63 | a 38 26 1 64 | a 38 37 1 65 | a 38 39 1 66 | a 39 38 1 67 | a 39 40 1 68 | a 40 28 1 69 | a 40 52 1 70 | a 40 39 1 71 | a 40 41 1 72 | a 41 53 1 73 | a 41 40 1 74 | a 41 42 1 75 | a 42 54 1 76 | a 42 41 1 77 | a 42 43 1 78 | a 43 55 1 79 | a 43 42 1 80 | a 43 44 1 81 | a 44 32 1 82 | a 44 56 1 83 | a 44 43 1 84 | a 47 59 1 85 | a 47 48 1 86 | a 48 36 1 87 | a 48 60 1 88 | a 48 47 1 89 | a 52 40 1 90 | a 52 64 1 91 | a 52 53 1 92 | a 53 41 1 93 | a 53 65 1 94 | a 53 52 1 95 | a 53 54 1 96 | a 54 42 1 97 | a 54 53 1 98 | a 54 55 1 99 | a 55 43 1 100 | a 55 54 1 101 | a 55 56 1 102 | a 56 44 1 103 | a 56 68 1 104 | a 56 55 1 105 | a 56 57 1 106 | a 57 69 1 107 | a 57 56 1 108 | a 57 58 1 109 | a 58 70 1 110 | a 58 57 1 111 | a 58 59 1 112 | a 59 47 1 113 | a 59 71 1 114 | a 59 58 1 115 | a 59 60 1 116 | a 60 48 1 117 | a 60 72 1 118 | a 60 59 1 119 | a 62 74 1 120 | a 62 63 1 121 | a 63 62 1 122 | a 63 64 1 123 | a 64 52 1 124 | a 64 76 1 125 | a 64 63 1 126 | a 64 65 1 127 | a 65 53 1 128 | a 65 77 1 129 | a 65 64 1 130 | a 68 56 1 131 | a 68 69 1 132 | a 69 57 1 133 | a 69 81 1 134 | a 69 68 1 135 | a 69 70 1 136 | a 70 58 1 137 | a 70 69 1 138 | a 70 71 1 139 | a 71 59 1 140 | a 71 83 1 141 | a 71 70 1 142 | a 71 72 1 143 | a 72 60 1 144 | a 72 71 1 145 | a 74 62 1 146 | a 74 86 1 147 | a 76 64 1 148 | a 76 77 1 149 | a 77 65 1 150 | a 77 89 1 151 | a 77 76 1 152 | a 77 78 1 153 | a 78 77 1 154 | a 78 79 1 155 | a 79 78 1 156 | a 81 69 1 157 | a 81 93 1 158 | a 83 71 1 159 | a 83 95 1 160 | a 85 97 1 161 | a 85 86 1 162 | a 86 74 1 163 | a 86 98 1 164 | a 86 85 1 165 | a 89 77 1 166 | a 89 101 1 167 | a 93 81 1 168 | a 93 105 1 169 | a 93 94 1 170 | a 94 106 1 171 | a 94 93 1 172 | a 94 95 1 173 | a 95 83 1 174 | a 95 107 1 175 | a 95 94 1 176 | a 95 96 1 177 | a 96 108 1 178 | a 96 95 1 179 | a 97 85 1 180 | a 97 98 1 181 | a 98 86 1 182 | a 98 110 1 183 | a 98 97 1 184 | a 100 112 1 185 | a 100 101 1 186 | a 101 89 1 187 | a 101 113 1 188 | a 101 100 1 189 | a 101 102 1 190 | a 102 114 1 191 | a 102 101 1 192 | a 102 103 1 193 | a 103 115 1 194 | a 103 102 1 195 | a 103 104 1 196 | a 104 116 1 197 | a 104 103 1 198 | a 104 105 1 199 | a 105 93 1 200 | a 105 104 1 201 | a 105 106 1 202 | a 106 94 1 203 | a 106 118 1 204 | a 106 105 1 205 | a 106 107 1 206 | a 107 95 1 207 | a 107 106 1 208 | a 107 108 1 209 | a 108 96 1 210 | a 108 120 1 211 | a 108 107 1 212 | a 110 98 1 213 | a 112 100 1 214 | a 112 113 1 215 | a 113 101 1 216 | a 113 125 1 217 | a 113 112 1 218 | a 113 114 1 219 | a 114 102 1 220 | a 114 126 1 221 | a 114 113 1 222 | a 114 115 1 223 | a 115 103 1 224 | a 115 114 1 225 | a 115 116 1 226 | a 116 104 1 227 | a 116 115 1 228 | a 118 106 1 229 | a 120 108 1 230 | a 120 132 1 231 | a 123 135 1 232 | a 125 113 1 233 | a 125 137 1 234 | a 125 126 1 235 | a 126 114 1 236 | a 126 138 1 237 | a 126 125 1 238 | a 131 132 1 239 | a 132 120 1 240 | a 132 144 1 241 | a 132 131 1 242 | a 134 135 1 243 | a 135 123 1 244 | a 135 134 1 245 | a 137 125 1 246 | a 137 138 1 247 | a 138 126 1 248 | a 138 137 1 249 | a 138 139 1 250 | a 139 138 1 251 | a 139 140 1 252 | a 140 139 1 253 | a 144 132 1 254 | -------------------------------------------------------------------------------- /app/genipafolio/genipafolio.cpp: -------------------------------------------------------------------------------- 1 | /* Author: Tomas Balyo, KIT, Karlsruhe */ 2 | 3 | #include 4 | #include 5 | #include "Threading.h" 6 | #include 7 | #include 8 | #include 9 | 10 | // The linked SAT solver might be written in C 11 | // while this application is written in C++ 12 | extern "C" { 13 | #include "ipasir.h" 14 | } 15 | 16 | using namespace std; 17 | 18 | // Parse a dimacs cnf formula from a given file and 19 | // save its clauses into a given vector. 20 | bool loadFormula(vector >& clauses, const char* filename) { 21 | FILE* f = fopen(filename, "r"); 22 | if (f == NULL) { 23 | return false; 24 | } 25 | int c = 0; 26 | bool neg = false; 27 | vector cls; 28 | while (c != EOF) { 29 | c = fgetc(f); 30 | // comment or problem definition line 31 | if (c == 'c' || c == 'p') { 32 | // skip this line 33 | while(c != '\n') { 34 | c = fgetc(f); 35 | } 36 | continue; 37 | } 38 | // whitespace 39 | if (isspace(c)) { 40 | continue; 41 | } 42 | // negative 43 | if (c == '-') { 44 | neg = true; 45 | continue; 46 | } 47 | // number 48 | if (isdigit(c)) { 49 | int num = c - '0'; 50 | c = fgetc(f); 51 | while (isdigit(c)) { 52 | num = num*10 + (c-'0'); 53 | c = fgetc(f); 54 | } 55 | if (neg) { 56 | num *= -1; 57 | } 58 | neg = false; 59 | if (num != 0) { 60 | cls.push_back(num); 61 | } else { 62 | clauses.push_back(vector(cls)); 63 | cls.clear(); 64 | } 65 | } 66 | } 67 | fclose(f); 68 | return true; 69 | } 70 | 71 | // This global variable is used to store the result of the solving 72 | // and also to signal that all the SAT solving threads can stop. 73 | int result = 0; 74 | 75 | // This function is called by the SAT solvers from different threads 76 | // to determine if they should abort solving of the formula. 77 | // A non-zero value indicates that the solver should abort (in accordance with 78 | // the ipasir definition). 79 | int terminator(void* state) { 80 | return result; 81 | } 82 | 83 | // Each thread is running this function which runs ipasir_solve 84 | void* solverThread(void* solver) { 85 | int res = ipasir_solve(solver); 86 | printf("c [genipafolio] solver stopped, res = %d\n", res); 87 | if (res != 0) { 88 | result = res; 89 | } 90 | return NULL; 91 | } 92 | 93 | // Returns a random number between 0 and Max 94 | int randGen(int Max) { 95 | return rand() % Max; 96 | } 97 | 98 | int main(int argc, char** argv) { 99 | 100 | puts("c [genipafolio] USAGE: ./pfolio dimacs.cnf [#threads=4]"); 101 | 102 | srand(2015); 103 | char* filename = argv[1]; 104 | int cores = 4; 105 | if (argc > 2) { 106 | cores = atoi(argv[2]); 107 | } 108 | 109 | void** solvers = (void**)malloc(cores*sizeof(void*)); 110 | Thread** threads = (Thread**)malloc(cores*sizeof(Thread*)); 111 | 112 | printf("c [genipafolio] Solving %s with %d cores using %s and shuffling.\n", filename, cores, ipasir_signature()); 113 | 114 | vector > fla; 115 | loadFormula(fla, filename); 116 | 117 | for (int i = 0; i < cores; i++) { 118 | // initialize the solver 119 | solvers[i] = ipasir_init(); 120 | // set temination callback 121 | ipasir_set_terminate(solvers[i], NULL, terminator); 122 | // add the clauses (might be shuffled) 123 | for (size_t j = 0; j < fla.size(); j++) { 124 | vector& cls = fla[j]; 125 | for (size_t k = 0; k < cls.size(); k++) { 126 | ipasir_add(solvers[i], cls[k]); 127 | } 128 | ipasir_add(solvers[i], 0); 129 | } 130 | // start the solver 131 | threads[i] = new Thread(solverThread, solvers[i]); 132 | // shuffle the clauses for the next solver 133 | random_shuffle(fla.begin(), fla.end(), randGen); 134 | } 135 | // wait for each solver to stop and release them 136 | for (int i = 0; i < cores; i++) { 137 | threads[i]->join(); 138 | ipasir_release(solvers[i]); 139 | } 140 | free(solvers); 141 | free(threads); 142 | printf("c [genipafolio] All done, result = %d\n", result); 143 | return result; 144 | } 145 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/libs/tclap/CmdLineInterface.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: CmdLineInterface.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. 8 | * All rights reverved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | #ifndef TCLAP_COMMANDLINE_INTERFACE_H 24 | #define TCLAP_COMMANDLINE_INTERFACE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | namespace TCLAP { 34 | 35 | class Arg; 36 | class CmdLineOutput; 37 | class XorHandler; 38 | 39 | /** 40 | * The base class that manages the command line definition and passes 41 | * along the parsing to the appropriate Arg classes. 42 | */ 43 | class CmdLineInterface 44 | { 45 | public: 46 | 47 | /** 48 | * Destructor 49 | */ 50 | virtual ~CmdLineInterface() {} 51 | 52 | /** 53 | * Adds an argument to the list of arguments to be parsed. 54 | * \param a - Argument to be added. 55 | */ 56 | virtual void add( Arg& a )=0; 57 | 58 | /** 59 | * An alternative add. Functionally identical. 60 | * \param a - Argument to be added. 61 | */ 62 | virtual void add( Arg* a )=0; 63 | 64 | /** 65 | * Add two Args that will be xor'd. 66 | * If this method is used, add does 67 | * not need to be called. 68 | * \param a - Argument to be added and xor'd. 69 | * \param b - Argument to be added and xor'd. 70 | */ 71 | virtual void xorAdd( Arg& a, Arg& b )=0; 72 | 73 | /** 74 | * Add a list of Args that will be xor'd. If this method is used, 75 | * add does not need to be called. 76 | * \param xors - List of Args to be added and xor'd. 77 | */ 78 | virtual void xorAdd( std::vector& xors )=0; 79 | 80 | /** 81 | * Parses the command line. 82 | * \param argc - Number of arguments. 83 | * \param argv - Array of arguments. 84 | */ 85 | virtual void parse(int argc, const char * const * argv)=0; 86 | 87 | /** 88 | * Parses the command line. 89 | * \param args - A vector of strings representing the args. 90 | * args[0] is still the program name. 91 | */ 92 | void parse(std::vector& args); 93 | 94 | /** 95 | * Returns the CmdLineOutput object. 96 | */ 97 | virtual CmdLineOutput* getOutput()=0; 98 | 99 | /** 100 | * \param co - CmdLineOutput object that we want to use instead. 101 | */ 102 | virtual void setOutput(CmdLineOutput* co)=0; 103 | 104 | /** 105 | * Returns the version string. 106 | */ 107 | virtual std::string& getVersion()=0; 108 | 109 | /** 110 | * Returns the program name string. 111 | */ 112 | virtual std::string& getProgramName()=0; 113 | 114 | /** 115 | * Returns the argList. 116 | */ 117 | virtual std::list& getArgList()=0; 118 | 119 | /** 120 | * Returns the XorHandler. 121 | */ 122 | virtual XorHandler& getXorHandler()=0; 123 | 124 | /** 125 | * Returns the delimiter string. 126 | */ 127 | virtual char getDelimiter()=0; 128 | 129 | /** 130 | * Returns the message string. 131 | */ 132 | virtual std::string& getMessage()=0; 133 | 134 | /** 135 | * Indicates whether or not the help and version switches were created 136 | * automatically. 137 | */ 138 | virtual bool hasHelpAndVersion()=0; 139 | 140 | /** 141 | * Resets the instance as if it had just been constructed so that the 142 | * instance can be reused. 143 | */ 144 | virtual void reset()=0; 145 | }; 146 | 147 | } //namespace 148 | 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /app/genipaessentials/genipaessentials.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * essentials.cpp 3 | * 4 | * Created on: Feb 3, 2015 5 | * Author: Tomas Balyo, KIT 6 | */ 7 | 8 | extern "C" { 9 | #include "ipasir.h" 10 | } 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | int getDualRailName(int lit) { 18 | if (lit == 0) { 19 | return 0; 20 | } 21 | if (lit > 0) { 22 | return 2*lit; 23 | } else { 24 | return 2*(-lit) - 1; 25 | } 26 | } 27 | 28 | /** 29 | * Reads a formula from a given file and transforms it using the dual rail encoding, 30 | * i.e., replaces each x by px and each \overline{x} by nx. Also adds clauses 31 | * of the form (\overline{px} \vee \overline{nx}) 32 | */ 33 | bool loadFormulaDualRailed(void* solver, const char* filename, int* outVariables) { 34 | FILE* f = fopen(filename, "r"); 35 | if (f == NULL) { 36 | return false; 37 | } 38 | int maxVar = 0; 39 | int c = 0; 40 | bool neg = false; 41 | while (c != EOF) { 42 | c = fgetc(f); 43 | 44 | // comment or problem definition line 45 | if (c == 'c' || c == 'p') { 46 | // skip this line 47 | while(c != '\n') { 48 | c = fgetc(f); 49 | } 50 | continue; 51 | } 52 | // whitespace 53 | if (isspace(c)) { 54 | continue; 55 | } 56 | // negative 57 | if (c == '-') { 58 | neg = true; 59 | continue; 60 | } 61 | 62 | // number 63 | if (isdigit(c)) { 64 | int num = c - '0'; 65 | c = fgetc(f); 66 | while (isdigit(c)) { 67 | num = num*10 + (c-'0'); 68 | c = fgetc(f); 69 | } 70 | if (neg) { 71 | num *= -1; 72 | } 73 | neg = false; 74 | 75 | if (abs(num) > maxVar) { 76 | maxVar = abs(num); 77 | } 78 | // add to the solver 79 | ipasir_add(solver, getDualRailName(num)); 80 | } 81 | } 82 | fclose(f); 83 | // add the extra clauses 84 | for (int var = 1; var <= maxVar; var++) { 85 | ipasir_add(solver, -getDualRailName(var)); 86 | ipasir_add(solver, -getDualRailName(-var)); 87 | ipasir_add(solver, 0); 88 | } 89 | *outVariables = maxVar; 90 | return true; 91 | } 92 | 93 | int lunits = 0; 94 | int lbins = 0; 95 | int lterns = 0; 96 | 97 | void learnCb(void* state, int* clause) { 98 | if (clause[0] == 0) ; 99 | else if (clause[1] == 0) lunits++; 100 | else if (clause[2] == 0) lbins++; 101 | else if (clause[3] == 0) lterns++; 102 | } 103 | 104 | int main(int argc, char **argv) { 105 | printf("Using the incremental SAT solver %s.\n", ipasir_signature()); 106 | 107 | if (argc != 2) { 108 | puts("USAGE: ./genipaessentials "); 109 | return 0; 110 | } 111 | 112 | puts("Given a satisfiable formula F and a variable x, we say that x is"); 113 | puts("essential for the satisfiability of F if a truth value (True or False)"); 114 | puts("must be assigned to x in each satisfying assignment of F. This application"); 115 | puts("finds all the variables essential for the satisfiability of a given formula."); 116 | 117 | void *solver = ipasir_init(); 118 | ipasir_set_learn(solver, NULL, 3, learnCb); 119 | int variables = 0; 120 | bool loaded = loadFormulaDualRailed(solver, argv[1], &variables); 121 | 122 | if (!loaded) { 123 | printf("The input formula \"%s\" could not be loaded.\n", argv[1]); 124 | return 0; 125 | } 126 | 127 | int satRes = ipasir_solve(solver); 128 | 129 | if (satRes == 20) { 130 | puts("The input formula is unsatisfiable."); 131 | return 0; 132 | } 133 | 134 | std::vector essentialVariables; 135 | for (int var = 1; var <= variables; var++) { 136 | printf("Testing if variable %d (out of %d) is essential for satisfiability.\n", var, variables); 137 | ipasir_assume(solver, -getDualRailName(var)); 138 | ipasir_assume(solver, -getDualRailName(-var)); 139 | satRes = ipasir_solve(solver); 140 | if (satRes == 10) { 141 | printf("Variable %d IS NOT essential for satisfiability.\n", var); 142 | } else { 143 | printf("Variable %d IS essential for satisfiability.\n", var); 144 | essentialVariables.push_back(var); 145 | } 146 | } 147 | int essentials = (int)essentialVariables.size(); 148 | printf("SUMMARY: %d of %d (%0.2f%%) of variables is essential for satisfiability.\n", 149 | essentials, variables, 100.0*essentials/variables); 150 | puts("The list of variables eseential for satisfiability:"); 151 | for (size_t i = 0; i < essentialVariables.size(); i++) { 152 | printf("%d ", essentialVariables[i]); 153 | } 154 | printf("\n"); 155 | printf("The solver shared %d unit, %d binary and %d ternary clauses.\n", lunits, lbins, lterns); 156 | return 0; 157 | } 158 | -------------------------------------------------------------------------------- /app/ipasir-check-iterative/ipasir-check-iterative.cc: -------------------------------------------------------------------------------- 1 | // Norbert Manthey, 2017 2 | 3 | // make sure we use IPASIR 4 | #define HAVE_IPASIR 5 | 6 | // declare IPASIR functions here, which we might need 7 | #include "SATSolver.h" 8 | 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | inline double cpuTime(void) 20 | { 21 | struct rusage ru; 22 | getrusage(RUSAGE_SELF, &ru); 23 | return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; 24 | } 25 | 26 | int main(int argc, char* argv[]) 27 | { 28 | std::cout << "Norbert Manthey -- IPASIR iterative load checker" << std::endl; 29 | std::cout << " add formula that has sub formulas of blocks" << std::endl 30 | << " use full stack of assumptions and modify last polarities per call" << std::endl; 31 | if(argc < 3) { 32 | std::cout << "usage: " << argv[0] << " X Y Z ... with 2 < X < 2^30, 1 < Y < 10, 1 < Z" << std::endl; 33 | return 1; 34 | } 35 | 36 | int X = atoi(argv[1]); 37 | int Y = atoi(argv[2]); 38 | int Z = atoi(argv[3]); 39 | 40 | if(X<3) { 41 | std::cout << "error: given first number " << X << " is not in limits" << std::endl; 42 | return 1; 43 | } 44 | 45 | if(Y<1 || Y>9) { 46 | std::cout << "error: given second number " << Y << " is not in limits" << std::endl; 47 | return 1; 48 | } 49 | 50 | if(Z < 2) { 51 | std::cout << "error: given third number " << Z << " is not in limits" << std::endl; 52 | return 1; 53 | } 54 | 55 | SATSolver solver; 56 | 57 | const int periodsize = (1 << Y); 58 | vector clause(Y,0); 59 | int index = 0; 60 | int clauses = 0; 61 | int maxvar = 0; 62 | for(int i = 1 ; i < periodsize; ++i) { 63 | index = i; 64 | int sum = 0; 65 | for(int j = 0 ; j < Y; ++j) { 66 | clause[j] = ((index & 1) == 0) ? j+1 : -j-1; 67 | sum += clause[j] > 0 ? 1 : -1; 68 | index = index >> 1; 69 | } 70 | assert(sum < (int)clause.size() && "clause with positive literals only should not be created"); 71 | 72 | for(int j = 0; j < Z; ++ j) { 73 | if(j>0) { 74 | for(int k=0; k < Y; ++k) { 75 | clause[k] = clause[k] > 0 ? clause[k] + Y : clause[k] - Y; 76 | maxvar = maxvar > clause[k] ? maxvar : clause[k]; 77 | } 78 | } 79 | solver.addClause(clause); 80 | clauses ++; 81 | } 82 | } 83 | 84 | std::cout << "created formula with " << clauses << " clauses, and maxvar " << maxvar << std::endl; 85 | 86 | vector assumptions; 87 | std::vector model; 88 | std::vector conflict; 89 | 90 | for(int i = 1 ; i <= maxvar; ++i) assumptions.push_back(-i); 91 | int ret = solver.solve(assumptions, model, conflict); 92 | std::cout << "initial call returned with " << ret << std::endl; 93 | if(ret != 10) 94 | { 95 | std::cout << "error: first call did not result in model, but " << ret << ", abort" << std::endl; 96 | return 1; 97 | } 98 | 99 | double runtime = cpuTime(); 100 | int call = 0; 101 | for(int i = 2; i <= X; ++ i) 102 | { 103 | // modify last bits of assumptions 104 | int mask = call; 105 | int index = 1; 106 | while(mask > 0 && index <= assumptions.size()) { 107 | if((mask & 1)==1) assumptions[assumptions.size() - index] = -assumptions[assumptions.size() - index]; 108 | mask = mask >> 1; 109 | index ++; 110 | } 111 | conflict.clear(); 112 | int ret = solver.solve(assumptions, model, conflict); 113 | call ++; 114 | if(i % 256 == 0) std::cout << " after " << i << " calls: " << (double)X / (cpuTime()-runtime) << " calls per second" << std::endl; 115 | if (ret==20) { 116 | solver.addClause(conflict); 117 | } else if (call!=1) { 118 | std::cout << "error: in call " << call << ", did not detect conflict (but " << ret << ") on unsatisfiable input, abort" << std::endl; 119 | std::cout << "used assumptions: " << assumptions << std::endl; 120 | return 1; 121 | } 122 | 123 | // modify last bits of assumptions 124 | mask = call; 125 | index = 1; 126 | while(mask > 0 && index <= assumptions.size()) { 127 | if(assumptions[assumptions.size() - index] > 0) assumptions[assumptions.size() - index] = -assumptions[assumptions.size() - index]; 128 | mask = mask >> 1; 129 | index ++; 130 | } 131 | } 132 | runtime = cpuTime() - runtime; 133 | std::cout << "performed " << (double)X / runtime << " calls per second" << std::endl; 134 | 135 | return 0; 136 | } 137 | 138 | -------------------------------------------------------------------------------- /sat/minisat220/ipasirminisatglue.cc: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 - 2014, Armin Biere, Johannes Kepler University, Linz */ 2 | /* Copyright (C) 2014, Mathias Preiner, Johannes Kepler University, Linz */ 3 | 4 | /* This file contains code original developped for the Boolector project, 5 | * but is also available under the standard IPASIR license. 6 | */ 7 | #define __STDC_LIMIT_MACROS 8 | #define __STDC_FORMAT_MACROS 9 | #include "Solver.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | using namespace Minisat; 19 | 20 | extern "C" { 21 | static const char * sig = "minisat" VERSION; 22 | #include 23 | #include 24 | static double getime (void) { 25 | struct rusage u; 26 | double res; 27 | if (getrusage (RUSAGE_SELF, &u)) return 0; 28 | res = u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec; 29 | res += u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec; 30 | return res; 31 | } 32 | }; 33 | 34 | class IPAsirMiniSAT : public Solver { 35 | vec assumptions, clause; 36 | int szfmap; unsigned char * fmap; bool nomodel; 37 | unsigned long long calls; 38 | void reset () { if (fmap) delete [] fmap, fmap = 0, szfmap = 0; } 39 | Lit import (int32_t lit) { 40 | while (abs (lit) > nVars ()) (void) newVar (); 41 | return mkLit (Var (abs (lit) - 1), (lit < 0)); 42 | } 43 | void ana () { 44 | fmap = new unsigned char [szfmap = nVars ()]; 45 | memset (fmap, 0, szfmap); 46 | for (int i = 0; i < conflict.size (); i++) { 47 | int tmp = var (conflict[i]); 48 | assert (0 <= tmp && tmp < szfmap); 49 | fmap[tmp] = 1; 50 | } 51 | } 52 | double ps (double s, double t) { return t ? s/t : 0; } 53 | public: 54 | IPAsirMiniSAT () : szfmap (0), fmap (0), nomodel (false), calls (0) { 55 | // MiniSAT by default produces non standard conforming messages. 56 | // So either we have to set this to '0' or patch the sources. 57 | verbosity = 1; 58 | } 59 | ~IPAsirMiniSAT () { reset (); } 60 | void add (int32_t lit) { 61 | reset (); 62 | nomodel = true; 63 | if (lit) clause.push (import (lit)); 64 | else addClause (clause), clause.clear (); 65 | } 66 | void assume (int32_t lit) { 67 | reset (); 68 | nomodel = true; 69 | assumptions.push (import (lit)); 70 | } 71 | int solve () { 72 | calls++; 73 | reset (); 74 | lbool res = solveLimited (assumptions); 75 | assumptions.clear (); 76 | nomodel = (res != l_True); 77 | return (res == l_Undef) ? 0 : (res == l_True ? 10 : 20); 78 | } 79 | int val (int32_t lit) { 80 | if (nomodel) return 0; 81 | lbool res = modelValue (import (lit)); 82 | return (res == l_True) ? lit : -lit; 83 | } 84 | int failed (int32_t lit) { 85 | if (!fmap) ana (); 86 | int tmp = var (import (lit)); 87 | assert (0 <= tmp && tmp < nVars ()); 88 | return fmap[tmp] != 0; 89 | } 90 | void stats () { 91 | double t = getime (); 92 | printf ( 93 | "c [%s]\n" 94 | "c [%s] calls %12llu %9.1f per second\n" 95 | "c [%s] restarts %12llu %9.1f per second\n" 96 | "c [%s] conflicts %12llu %9.1f per second\n" 97 | "c [%s] decisions %12llu %9.1f per second\n" 98 | "c [%s] propagations %12llu %9.1f per second\n" 99 | "c [%s]\n", 100 | sig, 101 | sig, (unsigned long long) calls, ps (calls, t), 102 | sig, (unsigned long long) starts, ps (starts, t), 103 | sig, (unsigned long long) conflicts, ps (conflicts, t), 104 | sig, (unsigned long long) decisions, ps (decisions, t), 105 | sig, (unsigned long long) propagations, ps (propagations, t), 106 | sig); 107 | fflush (stdout); 108 | } 109 | }; 110 | 111 | extern "C" { 112 | #include "ipasir.h" 113 | static IPAsirMiniSAT * import (void * s) { return (IPAsirMiniSAT*) s; } 114 | const char * ipasir_signature () { return sig; } 115 | void * ipasir_init () { return new IPAsirMiniSAT (); } 116 | void ipasir_release (void * s) { import (s)->stats (); delete import (s); } 117 | int ipasir_solve (void * s) { return import (s)->solve (); } 118 | void ipasir_add (void * s, int32_t l) { import (s)->add (l); } 119 | void ipasir_assume (void * s, int32_t l) { import (s)->assume (l); } 120 | int ipasir_val (void * s, int32_t l) { return import (s)->val (l); } 121 | int ipasir_failed (void * s, int32_t l) { return import (s)->failed (l); } 122 | void ipasir_set_terminate (void * s, void * state, int (*callback)(void * state)) { import(s)->setTermCallback(state, callback); } 123 | void ipasir_set_learn (void * s, void * state, int max_length, void (*learn)(void * state, int32_t * clause)) { import(s)->setLearnCallback(state, max_length, learn); } 124 | }; 125 | -------------------------------------------------------------------------------- /app/genipabones/genipabones.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * essentials.cpp 3 | * 4 | * Created on: Feb 3, 2015 5 | * Author: Tomas Balyo, KIT 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | extern "C" { 18 | #include "ipasir.h" 19 | } 20 | /** 21 | * Reads a formula from a given file and transforms it using the dual rail encoding, 22 | * i.e., replaces each x by px and each \overline{x} by nx. Also adds clauses 23 | * of the form (\overline{px} \vee \overline{nx}) 24 | */ 25 | bool loadFormula(void* solver, const char* filename, vector& boundary, int& maxVar) { 26 | FILE* f = fopen(filename, "r"); 27 | if (f == NULL) { 28 | return false; 29 | } 30 | maxVar = 0; 31 | int c = 0; 32 | bool neg = false; 33 | while (c != EOF) { 34 | c = fgetc(f); 35 | 36 | // comment or problem definition line 37 | if (c == 'c' || c == 'p') { 38 | c = fgetc(f); 39 | if (c == 'v' && fgetc(f) == 'i' && fgetc(f) == 'p' && fgetc(f) == ' ') { 40 | // boundary variables 41 | printf("c back-bone candidates specified in input file.\n"); 42 | int num = 0; 43 | while(c != '\n') { 44 | c = fgetc(f); 45 | while (isdigit(c)) { 46 | num = num*10 + (c-'0'); 47 | c = fgetc(f); 48 | } 49 | boundary.push_back(num); 50 | num = 0; 51 | } 52 | } 53 | // skip this line 54 | while(c != '\n') { 55 | c = fgetc(f); 56 | } 57 | continue; 58 | } 59 | // whitespace 60 | if (isspace(c)) { 61 | continue; 62 | } 63 | // negative 64 | if (c == '-') { 65 | neg = true; 66 | continue; 67 | } 68 | 69 | // number 70 | if (isdigit(c)) { 71 | int num = c - '0'; 72 | c = fgetc(f); 73 | while (isdigit(c)) { 74 | num = num*10 + (c-'0'); 75 | c = fgetc(f); 76 | } 77 | if (neg) { 78 | num *= -1; 79 | } 80 | neg = false; 81 | 82 | if (abs(num) > maxVar) { 83 | maxVar = abs(num); 84 | } 85 | // add to the solver 86 | ipasir_add(solver, num); 87 | } 88 | } 89 | fclose(f); 90 | return true; 91 | } 92 | 93 | int terminateFlag = 0; 94 | 95 | int terminateCallback(void * state) { 96 | return terminateFlag; 97 | } 98 | 99 | void watchdog(int sig) { 100 | terminateFlag = 1; 101 | } 102 | 103 | int main(int argc, char **argv) { 104 | printf("c This program finds back-bones of a CNF SAT formula. A back-bone is assignment fixed in all solutions.\n"); 105 | printf("c You can specify backbone candidates by adding a line starting with 'cvip' followed by variables names separated by space to the cnf file.\n"); 106 | printf("c You can specify a time limit (in seconds) for checking one backbone using the -t parameter.\n"); 107 | printf("c Using the incremental SAT solver %s.\n", ipasir_signature()); 108 | 109 | 110 | if (argc < 2) { 111 | puts("USAGE: ./bbones [-t=]"); 112 | return 0; 113 | } 114 | 115 | void *solver = ipasir_init(); 116 | vector boundary; 117 | int maxVar; 118 | bool loaded = loadFormula(solver, argv[1], boundary, maxVar); 119 | 120 | if (!loaded) { 121 | printf("The input formula \"%s\" could not be loaded.\n", argv[1]); 122 | return 0; 123 | } 124 | 125 | if (boundary.size() == 0) { 126 | boundary.clear(); 127 | for (int var = 1; var <= maxVar; var++) { 128 | boundary.push_back(var); 129 | } 130 | printf("c Will check all the variables (%d) for backbones.\n", maxVar); 131 | } else { 132 | printf("c Will check %lu candidates for backbones.\n", boundary.size()); 133 | } 134 | 135 | int timelimit = 0; 136 | if ((argc > 2 && argv[2][1] == 't')) { 137 | timelimit = atoi(argv[2]+3); 138 | printf("c Time limit per check is %d seconds\n", timelimit); 139 | ipasir_set_terminate(solver, NULL, terminateCallback); 140 | signal(SIGALRM, watchdog); 141 | } 142 | 143 | int bbonesFound = 0; 144 | 145 | for (size_t i = 0; i < boundary.size(); i++) { 146 | int candidate = boundary[i]; 147 | printf("c Checking canidate %d, (nr. %lu of %lu)\n", candidate, i+1, boundary.size()); 148 | // check positive case 149 | ipasir_assume(solver, candidate); 150 | terminateFlag = 0; 151 | alarm(timelimit); 152 | int res = ipasir_solve(solver); 153 | if (res == 20) { 154 | bbonesFound++; 155 | printf("%d 0\n", -candidate); 156 | continue; 157 | } 158 | alarm(0); 159 | 160 | // check negative case 161 | ipasir_assume(solver, -candidate); 162 | terminateFlag = 0; 163 | alarm(timelimit); 164 | res = ipasir_solve(solver); 165 | if (res == 20) { 166 | bbonesFound++; 167 | printf("%d 0\n", candidate); 168 | } 169 | alarm(0); 170 | } 171 | 172 | printf("c Found %d backbones\n", bbonesFound); 173 | } 174 | -------------------------------------------------------------------------------- /app/incplan/src/incplan/src/carj/carj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "carj/logging.h" 4 | 5 | #include "tclap/CmdLine.h" 6 | #include "json.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | template < class T > 14 | std::ostream& operator << (std::ostream& os, const std::vector& v) 15 | { 16 | os << "["; 17 | for (typename std::vector::const_iterator ii = v.begin(); ii != v.end(); ++ii) 18 | { 19 | os << " " << *ii; 20 | } 21 | os << "]"; 22 | return os; 23 | } 24 | 25 | namespace carj { 26 | using json = nlohmann::json; 27 | 28 | class Carj; 29 | class CarjArgBase; 30 | 31 | Carj& getCarj(); 32 | std::vector& getArgs(); 33 | 34 | void init(int argc, const char **argv, TCLAP::CmdLine& cmd, 35 | std::string parameterBase); 36 | 37 | class Carj { 38 | public: 39 | static const std::string configPath; 40 | 41 | Carj() { 42 | } 43 | 44 | void init(std::string inputPath = configPath, 45 | bool loadFromDefault = false, 46 | std::string base = "") { 47 | if (loadFromDefault) { 48 | std::ifstream inStream(inputPath); 49 | if (inStream) { 50 | inStream >> data; 51 | } 52 | } 53 | json::json_pointer p(base); 54 | parameter = &data[p]; 55 | } 56 | 57 | ~Carj(){ 58 | std::ofstream o(configPath); 59 | o << std::setw(4) << data << std::endl; 60 | } 61 | 62 | json data; 63 | json* parameter; 64 | }; 65 | 66 | class CarjArgBase { 67 | public: 68 | CarjArgBase(){ 69 | getArgs().push_back(this); 70 | } 71 | 72 | virtual ~CarjArgBase(){ 73 | 74 | } 75 | 76 | virtual void writeToJson() = 0; 77 | 78 | static void writeAllToJson() { 79 | for (CarjArgBase* arg: getArgs()) { 80 | arg->writeToJson(); 81 | } 82 | } 83 | }; 84 | 85 | template 86 | class CarjArgImpl: public CarjArgBase { 87 | public: 88 | template 89 | CarjArgImpl(Args&&... params): 90 | parameter(std::forward(params)...) { 91 | } 92 | 93 | virtual ~CarjArgImpl(){ 94 | 95 | } 96 | 97 | virtual void writeToJson() { 98 | auto it = getCarj().parameter->find(parameter.getName()); 99 | if (it != getCarj().parameter->end()) { 100 | if (parameter.isSet()) { 101 | json old = *it; 102 | ValueType oldValue = old.get(); 103 | if (oldValue != parameter.getValue()) { 104 | LOG(WARNING) 105 | << "Overwriting setting in config file for parameter " 106 | << parameter.getName() 107 | << "."; 108 | 109 | LOG(INFO) 110 | << "old setting: " << oldValue 111 | << " new setting: " << parameter.getValue(); 112 | } 113 | (*getCarj().parameter)[parameter.getName()] = parameter.getValue(); 114 | } 115 | } else { 116 | (*getCarj().parameter)[parameter.getName()] = parameter.getValue(); 117 | } 118 | } 119 | 120 | ValueType getValue(){ 121 | ValueType value = parameter.getValue(); 122 | try 123 | { 124 | // the value is contained in the json file (as we write back 125 | // parameters to the json, this is the case for parameters) 126 | json a = getCarj().parameter->at(parameter.getName()); 127 | try { 128 | value = a.get(); 129 | } catch (std::domain_error& e) { 130 | LOG(ERROR) << "Configuration File invalid. " 131 | << "std::domain_error for " 132 | << parameter.getName() << ": " 133 | << e.what(); 134 | LOG(WARNING) << "Using default value: " 135 | << parameter.getName() << " = " << value; 136 | } 137 | } 138 | catch (std::out_of_range) 139 | { 140 | 141 | } 142 | return value; 143 | } 144 | 145 | private: 146 | TemplateType parameter; 147 | }; 148 | 149 | template