clasp-3.1.4/0000755000404600007640000000000012632272510012327 5ustar kaufmanncoolsclasp-3.1.4/configure.bat0000644000404600007640000001630112632266302015003 0ustar kaufmanncools@ECHO OFF SETLOCAL EnableDelayedExpansion REM OPTIONS set static=0 set machine=0 set mt=0 set PREFIX=%HOMEDRIVE%%HOMEPATH% set BIN_DIR= set CONFIG= REM CONFIGURATION set CXXFLAGS=%CXXFLAGS% set LIBS=libclasp libprogram_opts set LDFLAGS=%LDFLAGS% set LDLIBS= set BUILDPATH=build\release set INSTALLPATH=%PREFIX%\bin SET INCLUDES= SET LIB_TARGETS= set CXX= set POST_BUILD= SET TBB_LIB= SET TBB_INCLUDE= REM Scan arguments. :ARG_LOOP IF [%1]==[] ( GOTO DONE ) ELSE IF [%1]==[/?] ( goto o_help ) ELSE IF [%1]==[--help] ( :o_help ECHO. ECHO. %0 [ options ] ECHO. ECHO.Options: ECHO. ?,--help : print this page ECHO. --prefix=PATH : set install prefix to PATH ECHO. --bindir=PATH : set install path to PATH ECHO. ECHO. --config=NAME : set configuration to NAME ECHO. NAME=release: configure for optimized release version ECHO. NAME=debug : configure for debug version ECHO. NAME=check : configure for release version with assertions enabled ECHO. ELSE : configure for custom configuration ECHO. ECHO --with-mt : enable multi-thread support ^(see below^) ECHO --static : link statically ^(if supported^) ECHO. --m32 : force 32-bit binary ^(if supported^) ECHO. --m64 : force 64-bit binary ^(if supported^) ECHO. --strip : discard symbols ^(calls strip after build^) ECHO. --clean : remove all generated files ECHO. ECHO. Note: Multi-thread support requires Intel Threading Building Blocks 3.x. ECHO. Use option --with-mt and either set TBB30_INSTALL_DIR environment ECHO. variable or explicitly set include and/or library path via: ECHO. %0 --with-mt TBB_INCLUDE=^ TBB_LIB=^ ECHO. ECHO. Note: To create a custom configuration call %0 like this: ECHO. %0 --config=my_c CXX=my_gcc CXXFLAGS=my_cxxf LDFLAGS=my_ldf ECHO. GOTO EXIT ) ELSE IF [%1]==[CXX] ( SET CXX=%2 SHIFT ) ELSE IF [%1]==[CXXFLAGS] ( SET CXXFLAGS=%2 SHIFT ) ELSE IF [%1]==[LDFLAGS] ( SET LDFLAGS=%2 SHIFT ) ELSE IF [%1]==[TBB_INCLUDE] ( SET TBB_INCLUDE=%2 SHIFT ) ELSE IF [%1]==[TBB_LIB] ( SET TBB_LIB=%2 SHIFT ) ELSE IF [%1]==[--prefix] ( SET PREFIX=%2 SHIFT ) ELSE IF [%1]==[--bindir] ( SET BIN_DIR=%2 SHIFT ) ELSE IF [%1]==[--config] ( if not [%CONFIG%]==[] ( ECHO *** Error: multiple values for option '--config' goto EXIT ) set CONFIG=%2 SHIFT ) ELSE IF [%1]==[--static] ( SET static=1 ) ELSE IF [%1]==[--with-mt] ( SET mt=1 ) ELSE IF [%1]==[--m32] ( SET machine=32 ) ELSE IF [%1]==[--m64] ( SET machine=64 ) ELSE IF [%1]==[--strip] ( SET POST_BUILD=strip ) ELSE IF [%1]==[--clean] ( IF NOT EXIST build goto EXIT RD /S /Q build goto EXIT ) ELSE ( ECHO *** Error: Unknown parameter '%1'. ECHO Type '%0 /?' for an overview of supported options. GOTO EXIT ) SHIFT GOTO ARG_LOOP :DONE if [%CONFIG%]==[] ( set CONFIG=release ) if [%CONFIG%]==[release] ( SET CXXFLAGS=-O3 -DNDEBUG ) ELSE IF [%CONFIG%]==[debug] ( SET CXXFLAGS=-g -D_DEBUG -DDEBUG -O1 ) ELSE IF [%CONFIG%]==[check] ( SET CXXFLAGS=-O2 -DDEBUG ) IF ["%CXXFLAGS%"]==[""] ( SET CXXFLAGS=-O3 -DNDEBUG ) SET BUILDPATH=build\%CONFIG% IF %mt%==0 ( SET CXXFLAGS=%CXXFLAGS% -DWITH_THREADS=0 ) ELSE ( if [%TBB_INCLUDE%]==[] ( set TBB_INCLUDE=%TBB30_INSTALL_DIR%/include ) if [%TBB_LIB%]==[] ( set TBB_LIB=%TBB30_INSTALL_DIR%/lib ) IF NOT EXIST "%TBB_INCLUDE%/tbb/tbb.h" ( ECHO *** Error: TBB include path not set! ECHO Use 'configure TBB_INCLUDE=^/include' GOTO EXIT ) IF NOT EXIST "%TBB_LIB%/tbb.lib" ( ECHO *** Error: TBB library path not set or '%TBB_LIB%/tbb.lib' not found! ECHO Use 'configure TBB_LIB=^' GOTO EXIT ) SET CXXFLAGS=%CXXFLAGS% -DWITH_THREADS=1 -I"%TBB_INCLUDE%" SET LDFLAGS=%LDFLAGS% -L"%TBB_LIB%" -Xlinker -rpath -Xlinker "%TBB_LIB%" SET LDLIBS=-ltbb SET BUILDPATH=%BUILDPATH%_mt ) SET CXXFLAGS=%CXXFLAGS% IF %static%==1 ( SET LDFLAGS=%LDFLAGS% -static SET BUILDPATH=%BUILDPATH%_static ) IF NOT %machine%==0 ( SET LDFLAGS=%LDFLAGS% -m%machine% SET CXXFLAGS=%CXXFLAGS% -m%machine% SET BUILDPATH=%BUILDPATH%_m%machine% ) IF [%BIN_DIR%]==[] ( SET INSTALLPATH=%PREFIX%\bin ) ELSE ( SET INSTALLPATH=%BIN_DIR% ) REM create & prepare build hierarchy IF NOT EXIST "%BUILDPATH%" goto CREATEDIR RD /S /Q "%BUILDPATH%" :CREATEDIR MKDIR "%BUILDPATH%\app" MKDIR "%BUILDPATH%\bin" SET INCLUDES= SET LIB_TARGETS= FOR %%A IN (%LIBS%) DO ( MKDIR "%BUILDPATH%\%%A\lib" SET INCLUDES=-I$^(PROJECT_ROOT^)/%%A !INCLUDES! SET LIB_TARGETS=%%A/lib/%%A.a !LIB_TARGETS! ) SET ROOTPATH=../.. SET TARGET=bin/clasp.exe cd "%BUILDPATH%" REM write FLAGS if ["%CXX%"]==[""] ( echo CXX ?= g++# >> FLAGS ) ELSE ( echo CXX := %CXX%# >> FLAGS ) echo CXXFLAGS := %CXXFLAGS%# >> FLAGS echo WARNFLAGS := -W -Wall# >> FLAGS echo LDFLAGS := %LDFLAGS%# >> FLAGS echo.#>> FLAGS REM create Makefiles SET TOOL_PATH=..\..\tools SET LIB_MAKES=%TOOL_PATH%\Base.in %TOOL_PATH%\LibRule.in %TOOL_PATH%\BaseRule.in SET PRO_MAKES=%TOOL_PATH%\Base.in %TOOL_PATH%\ProjRule.in %TOOL_PATH%\BaseRule.in FOR %%A IN (%LIBS%) DO type %LIB_MAKES% > %%A\Makefile 2>nul type %PRO_MAKES% > Makefile 2>nul REM write project config echo PROJECT_ROOT := %ROOTPATH%# >> .CONFIG echo TARGET := %TARGET%# >> .CONFIG echo FLAGS := FLAGS# >> .CONFIG echo SOURCE_DIR := $(PROJECT_ROOT)/app# >> .CONFIG echo INCLUDE_DIR := $(PROJECT_ROOT)/app# >> .CONFIG echo OUT_DIR := app# >> .CONFIG echo INCLUDES := %INCLUDES%# >> .CONFIG echo SUBDIRS := %LIBS%# >> .CONFIG echo LIBS := %LIB_TARGETS%# >> .CONFIG echo LDLIBS := %LDLIBS%# >> .CONFIG echo INSTALL_DIR := "%INSTALLPATH%"# >> .CONFIG echo INSTALL := copy# >> .CONFIG if not [%POST_BUILD%]==[] ( ECHO POST_BUILD := %POST_BUILD%# >> .CONFIG ) echo.#>>.CONFIG REM write lib configs FOR %%A IN (%LIBS%) DO ( set x=%%A echo PROJECT_ROOT := %ROOTPATH%/..# >> %%A\.CONFIG echo TARGET := lib/%%A.a# >> %%A\.CONFIG echo LDLIBS := %LDLIBS%# >> %%A\.CONFIG echo FLAGS := ../FLAGS# >> %%A\.CONFIG echo INCLUDES := !INCLUDES!# >> %%A\.CONFIG echo SOURCE_DIR := $^(PROJECT_ROOT^)/%%A/src# >> %%A\.CONFIG echo INCLUDE_DIR := $^(PROJECT_ROOT^)/%%A/!x:~3!# >> %%A\.CONFIG echo.# >> %%A\.CONFIG ) REM DONE ECHO. ECHO Configuration successfully written to %BUILDPATH%. ECHO Make flags written to "%BUILDPATH%\FLAGS". ECHO. ECHO To compile clasp type: ECHO cd "%BUILDPATH%" ECHO make ECHO. ECHO To install clasp afterwards type: ECHO make install ECHO or copy "%BUILDPATH%\%TARGET%" to a directory of your choice. IF EXIST "%INSTALLPATH%" goto skip_warn ECHO. ECHO Note: Path "%INSTALLPATH%" does not exist! ECHO Installation will fail unless it is first created! :skip_warn ECHO. ECHO Note: 'make' must correspond to GNU Make 3.8 or later. ECHO. :EXIT (set static=) (set machine=) (set mt=) (set PREFIX=) (set BIN_DIR=) (set CONFIG=) (set LDFLAGS=) (set LDLIBS=) (set BUILDPATH=) (set CXXFLAGS=) (set INSTALLPATH=) (set CXX=) (set TARGET=) (set POST_BUILD=) (set LIB_MAKES=) (set PRO_MAKES=) (set TOOL_PATH=) (set TBB_LIB=) (set TBB_INCLUDE=) (set LIBS=) (set INCLUDES=) (set LIB_TARGETS=)clasp-3.1.4/CHANGES0000644000404600007640000010766512632266302013343 0ustar kaufmanncoolsclasp 3.1.4: Thursday, 10th December 2015 * fixed: "--pre" failed to handle choice/disjunctive heads defined by extended bodies * fixed: "--backprop" failed to backpropagte certain constraints when used with "--eq=0" * fixed: potential deadlock during shutdown/join() in async solving * fixed: DomainHeuristic failed to handle nested heuristic predicates * fixed: invalid delete in DomainHeuristic destructor * fixed: configuration sometimes failed to initialize solver id * rewrote Clause::updateWatch() loop to workaround bug #67892 in gcc 5 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67892) clasp 3.1.3: Friday, 31th July 2015 * fixed: possible livelock in multi-threaded enumeration of optimal models * fixed: parser for _heuristic atoms failed to handle atoms containing strings * fixed: over-satisfied PB constraints not always handled correctly * fixed: incorrect handling of aux vars in Solver::numWatches() * fixed: C++11 isnan issue on Mac clasp 3.1.2: Tuesday, 5th May 2015 * fixed: Option "--heuristic" failed to accept decay factor for domain heuristic * fixed: LogicProgram::getDisjFor() failed to handle hash collisions correctly * fixed: facts in disjunctions not always correctly handled * fixed: domain heuristic failed to distinguish atom names sharing a common prefix * fixed: domain heuristic failed to handle atoms with complementary literals correctly * fixed: LogicProgram::write() must not output gamma rules and/or atoms that are false * fixed regression in handling of sign modifier in domain heuristic * fixed regression in backpropagation during preprocessing clasp 3.1.1: Wednesday, 12th November 2014 * LparseReader now handles "external statement" * fixed: low-level config interface failed to correctly handle successive changes of "opt-bound" * fixed: wrong completition nogoods with option "--no-gamma" * fixed regression in rule simplification (regression in 3.0.x) * fixed regression in "--configuration=jumpy" * fixed regression in handling of modifiers true/false in domain heuristic clasp 3.1.0: Friday, 15th August 2014 * added new strategies for unsatisfiable-core based optimization * added alternative distribution mode via thread-local queues (option " --dist-mode") * generators now propagate top-level assignment to testers * removed optimization options from default configurations * CLI changes: - option "--sat-prepro" now expects the algorithm followed by an optional list of limits - option "--opt-strategy" now takes two arguments; the first mandatory argument selects the major strategy (i.e. branch and bound or unsat-core), while the optional second argument controls fine tuning of said strategy - combined options "--dom-mod" and "--dom-pref" and added enum mode "domRec" for enabling subset optimization via domain heuristic - added "--forget-on-step=2" for discarding previously set variable phases and changed value for discarding nogood activities and learnt nogoods to 4 and 8, respectively - replaced option "--hparam" (and its aliases) with second argument for "--heuristic" - replaced "--berk-once" with more general "--score-res" - renamed option "--number" to "--models" * Integration/clingo: - added support for open (i.e. unassigned) externals - added support for adding constraints via model callback - added low-level interface for accessing a clasp configuration - cleaned up some stats keys and replaced "camelCase" with "snake_case" in keys clasp 3.0.6: Monday, 21st July 2014 * fixed: parallel unsat-core based enumeration of optimal models could skip valid models * fixed: possible race condition in signal handling * fixed: ABA-problem in parallel cb-enumerator could lead to duplicate models (regression in 3.0.x) * fixed: "--share=auto" (default) failed to enable physical sharing in mt-mode (regression in 3.0.x) * fixed: eq over complementary atoms not always correctly handled (regression in 3.0.x) * fixed: incremental domain heuristic failed to apply values to atoms from previous steps * fixed: eq over bodies of size 1 not always correctly handled * fixed: typo in description of "--quiet" clasp 3.0.5: Monday, 19th May 2014 * added support for ThreadTime::getTime() on MacOS X * removed pointless "--del-init" option from config tweety * fixed: non-hcf components not always correctly added in incremental disjunctive programs (clingo) * fixed: empty soft clauses not correctly handled in MaxSAT frontend * fixed: unfounded sets from 2nd level test not always correctly handled * fixed: json output must not print NaN * fixed: asp options not correctly set on configuration update (from clingo) * fixed: regression in handling of (incremental) projection clasp 3.0.4: Thursday, 24th April 2014 * replaced "s SATISFIABLE" with "s UNKNOWN" when called with option "--opt-sat" * improved handling of weight constraints containing incremental assumptions * fixed: typo in output of "--help" * fixed: unsatisfiable-core based optimization sometimes fails to assign all active assumptions * fixed: superfluous rules for facts not always correctly handled * fixed: assigned values for external atoms not always carried over to next step * fixed: clasp sometimes fails on incremental problems if "--lookahead" is used with "--forget-on-step" clasp 3.0.3: Friday, 28th March 2014 * fixed: AsyncResult destructor fails if called after destruction of ClaspFacade * fixed: projective enumeration sometimes fails when used with option "--restart-on-model" * fixed: regression in handling of negative lower bound in optimization clasp 3.0.2: Monday, 17th March 2014 * patch 1 (March 19th, 2014): fixed regression in projective enumeration * added ClaspFacade::startSolveAsync() for enumerating models in an iterator-like fashion * added "--forget-on-step" for simulating iclingo's "--ilearnt" and "--iheuristic" * added "--dom-mod=6" for simulating hclasp's subset minimization * fixed: DefaultUnfoundedCheck sometimes fails with assertion in incremental setting * fixed: wcnf frontend fails if top weight >= 2^31 * fixed: unit cores not always correctly handled in unsatisfiable-core based optimization * fixed: negative lower bound not correctly handled in hierarchical optimization * fixed: projection not correctly handled in incremental setting * fixed: clasp sometimes reports bogus timing values when interrupted via Ctrl-C on Windows * fixed: lookahead fails on non-asp problems if combined with option "--nant" * fixed: wrong/missing models because of incorrect backpropagation with option "--backprop" clasp 3.0.1: Friday, 21th February 2014 * added support for disabling "--opt-bound" via "--opt-bound=no" * added support for passing on/off values for option flags on config update * fixed: multiple occurrences of literal with negative weight not correctly merged (see also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739628) * fixed: negative literals not correctly formatted in PB output * fixed: excess bounds in "--opt-bound" not correctly handled * fixed: negatable otions like "[no]-init-moms" not recognized * fixed libprogram_opts: string to long long conversion fails clasp 3.0.0: Friday, 14th February 2014 1. Integrated support for disjunctive solving from claspD-2 2. Integrated domain heuristic from hclasp via option "--heuristic=domain" * added "--dom-pref" and "--dom-mod" for applying domain modifications to certain subsets of atoms 3. Optimization * replaced global "--opt-hierarch" option with more general per thread option "--opt-strategy" to enable competition-based optimization during parallel solving * integrated unsatisfiable-core based optimization from unclasp via "--opt-strategy={4,5}" * replaced "--opt-ignore", "--opt-all", "--opt-best" with option "--opt-mode" and added new reasoning mode for enumerating optimal models via option "--opt-mode=optN" * renamed "--opt-value" to "--opt-bound" 4. Misc * added a new configuration "tweety" and made it the default for asp problems * removed option "--portfolio" in favour of "--configuration=" * added second argument to "--contraction" for replacing long nogoods with decision sequence/all uip clause * added option "--out-hide-aux" for hiding atoms starting with "_" in models * added option "--out-atomf" for setting atom output format * added "--outf=3" for disabling output * simplified deletion options 5. Internals & Integration with clingo * implemented new configuration class * moved option handling and output classes to libclasp * simplified/cleaned up major interfaces * added support for asynchronous solving * added support for incremental/volatile enumeration/optimization * added support for adding/removing aux variables during solving * added low-level interface for accessing statistics clasp 2.1.5: Tuesday, 28th January 2014 * fixed a bug in the handling of unary projection nogoods * fixed a bug in the interplay between lookahead and minimization clasp 2.1.4: Tuesday, 26th November 2013 * fixed a possible crash bug in handling of conditional constraints * fixed a regression in handling of physically shared clauses * fixed compilation issues with clang-500.2.79 on Mac clasp 2.1.3: Friday, 12th April 2013 * fixed a regression in the handling of choice rules in the unfounded set checker clasp 2.1.2: Friday, 5th April 2013 * updated "--outf=1" to ASP-Comp'13 format and added corresponding exit codes * fixed: Wrong/missing models because of incorrect handling of recursive aggregates * fixed: Counter implication restart on root level could introduce an invalid conflict * fixed: clasp does not compile in C++11 mode * fixed regression: Inconsistent behaviour in dimacs front-end when running with or without option "--number=1" clasp 2.1.1: Thursday, 22th November 2012 * fixed regression: MaxSAT-frontend must not assert pure literals / relaxation variables * fixed: spurious warning when using option "--no-lookback" * fixed: "--shuffle" and "--counter-restarts" not working as intended with hierarchical optimization * fixed: Backslashes in JSON output not correctly quoted clasp 2.1.0: Monday, 27th August 2012 * restructured help and revised options and their defaults * added "--help[={1..3}]" for showing basic, advanced, or all options * added "--configuration" for selecting between prefabricated default configurations * revised deletion options and grouped them via common prefix "--del-" * revised thread options and added options for size-/topology-based lemma exchange * added support for dynamic restarts via "--restarts=D," * added "--sign-def" for setting default sign used in decision heuristic * added "--sign-fix" for disabling sign-heuristic * added "--init-moms" for enabling/disabling initialization of heuristic with MOMS-score * added "--fast-exit" for forcing app exit without cleanup * added "--update-act" for enabling LBD-based activity bumping * added "--update-mode" for configuring when update/integrate messages are handled in parallel-search * added "--learn-explicit" to disable usage of implication graph for learnt constraints * added "--share" for configuring physical constraint sharing * added "--init-watches" for controlling initialization of watched literals * added "--counter-restarts" and "--counter-bump" for enabling counter implication restarts * added "--lemma-out-lbd" for restricting lemmas written via "--lemma-out" * added "--lemma-in-lbd" for setting initial lbd of lemmas read via "--lemma-in" * replaced "--loops-in-heu" with more general "--score-other" * replaced "--rand-watches" with more general "--init-watches" * replaced "--initial-lookahead" with "--lookahead=[,]" * replaced "--recursive-str" with "--strengthen=[,]" * replaced "--copy-problem" with more general "--share" * removed options "--brave", "--cautious", "--solution-recording": all superseded by "--enum-mode=" * option "--restarts" now always requires a type; and the "limit" parameter now sets the (initial) length of the sequence * disbaled signal handling during printing of models * fixed: Overflow on parsing large opt-values (issue 3528852) * fixed: Parallel bt-enumerator enumerated duplicate models under certain conditions * fixed: Sat-Preprocessor failed to expand models correctly under very rare conditions * fixed: Erroneous interplay between "otfs=2" and "reverse-arcs" could lead to the unjustified removal of problem constraints * fixed: Incorrect ordering-predicate in MinimizeConstraint could lead to wrong optima * fixed: Solve loop failed to handle restart on total assignment correctly resulting in an infinite loop on some optimization problems * fixed: Duplicate key in JSON-Output of lemma stats clasp 2.0.6: Tuesday, 3rd April 2012 * added better error detection to portfolio parser and fixed a bug in the initialization of thread configs * first attempt at decoupling learnt db growing from restart schedule using independent grow schedule configurable via (hidden) option "--dgrowS" * added "--update-lbd=2" to enable usage of "strict" lbds * added (experimental) support for counter implication restarts and dynamic restarts via hidden options * fixed bugs in code for shared clause integration that could led to unpleasant results ranging from duplicate/missing models in enumeration to crashing if option "--otfs" was used clasp 2.0.5: Sunday, 29th January 2012 * fixed: Input parser for opb and (w)cnf failed to read 64bit integers. * fixed: Outer bound of inner-outer-restarts sometimes remained constant because of integer arithmetic. * fixed: Minimize constraint must not update optimum in enumeration-mode (opt-all). Bug introduced in version 2.0.3 * fixed: Minimize constraint must not update initial (user-set) bound until a model is found. Bug introduced in version 2.0.3 * fixed: Right hand side of minimize constraint not correctly initialized if "--opt-hierarch" was used. * fixed: SharedMinimizeData assumed monotonicity of individual levels - could fail after merging complementary literals in multi-level minimize constraints. Added extra "adjustment"-values to represent values resulting from such merges. clasp 2.0.4: Tuesday, 29th November 2011 * some cleanup in help output * moved general ASP-specific options to separate group * moved "--opt-sat" to basic options * simplified default command-line and made "input-dependent" defaults more explicit * updated interface spec of ProgramBuilder to make it more robust w.r.t incremental update * fixed parsing of "--global-restarts" * fixed: default value for option "--rand-watches" was not applied * fixed: Enumerator did not broadcast last model/optimum of current GP in parallel search * fixed: clauses simplified to binary/ternary are no longer counted twice in stats * fixed: eq-preprocessor sometimes did not reorder head list after merging two bodies * fixed: dimacs front-end failed to read empty dimacs file clasp 2.0.3: Tuesday, 23rd August 2011 * added option "--enum-mode" for setting enumeration algorithm and deprecated superseded options "--solution-recording", "--brave", and "cautious" * made "--enum-mode=record" the default for optimization * added default portfolio settable via "--portfolio=default" * added support for arithmetic restarts * moved "--opt-heuristic" to "Search Options" to allow for different settings in portfolios * fixed: clasp crashes with --pre (issue 3393095) * fixed: value given via "--opt-val" not checked against initial inconsistency * fixed: command line options not applied to portfolio configurations * fixed: parallel enumeration of models did not always respect "--number" * fixed: possible deadlock in parallel hierarchical optimization * fixed: failed to always propagate literals enqueued by PostPropagator::isModel() * fixed: possible crash bug because ReasonStore32::value_type did not decode stored data clasp 2.0.2: Thursday, 30th June 2011 * applied fixes from version 1.3.9 * fixed problem in call to linker (issue 3324430) * fixed a bug in "otfs" which could not handle unsimplified lemmas * fixed a potential invalid memory access in ImplicationList::hasLearnt() * fixed potential underflow in output of solved guiding paths * fixed a problem in UnitHeuristic which failed to handle stop conflicts in parallel solving * fixed various exception-related issues in parallel solving and made it more robust in the face of exceptions * re-enabled optimized unit clause handling for MaxSAT clasp 2.0.1: Wednesday, 27th April 2011 * fixed various (spurious) warnings * updated ProgramOptions to circumvent tellg() bug in g++-4.{4,5,6} under Debian (see also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=623850) * fixed some issues in build scripts (many thanks to Thomas Krennwallner) * configure.sh no longer sets RPATH unless "--set-rpath" is given * check for libtbb now also works on Mac OS * added code for finding TBB in default paths * fixed argument order in calls to compiler * removed spaces in specification of include/library directories clasp 2.0.0: Thursday, 21st April 2011 1. Support for parallel (multithreaded) solving (requires Intel(R) Threading Building Blocks) * configurable number of threads via option "--threads" * splitting-based search via guiding path and dynamic load-balancing * global restarts via option "--global-restarts" to escape from bad initial splits * competition-based search via freely configurable portfolios (option "--portfolio") * combination of splitting-based and portfolio-based search (option "--force-gp") * configurable lemma exchange via Distributor interface and options "--distribute" and "--integrate" * support for parallel enumeration, optimization, and computation of brave-/cautious consequences 2. Optimization * hierarchical (multi-level) optimization via option "--opt-hierarch=1" * hierarchical optimization with varying step lengths via option "--opt-hierarch={2,3}" * changed switch "--opt-heu" to option "--opt-heuristic={1,2,3}", where * 1: use optimize statements in sign heuristic * 2: use optimize statements in model heuristic * 3: use optimize statements in both sign and model heuristic * changed switch "--opt-all" to option "--opt-all=value"; now enumerates all models with optimize value less than or equal to given value 3. New language front-ends * added support for MaxSAT via optimization (option "--opt-sat") * added support for weighted partial MaxSAT problems in wcnf format * added support for weighted boolean optimization (WBO) problems * added support for non-linear constraints to pseudo-Boolean parser 4. New output handling * option "--outf={0,1,2}" for selecting between (0) default output format, (1) competition output format, and (2) output in JSON format * option "--quiet" now accepts a pair for configuring printing of models and optimize values * added verbosity level 3 to enable printing of progress messages * new (hidden) option "--ifs" for setting separator used when printing models 5. Preprocessing & Learning * added (optional) support for blocked clause elimination to SAT-preprocessor * added option "--reverse-arcs" for ManySAT-like conflict analysis with "reverse arcs" * added option "--otfs" for enabling "on the fly subsumption" * added (optional) support for secondary nogood reduction schedule via option "--dsched" * added option "--dinit=min,max" for limiting initial learnt db size to range [min,max] * added option "--dglue=x" to prevent deletion of nogoods with lbd <= x * added option "--update-lbd" for enabling dynamic updates of lbds of learnt nogoods 6. Internals * reimplemented constraints to enable sharing (and cloning); forced clear distinction between read-only, shared, and thread-local data * separated read-only program dependency graph from thread-local unfounded set checker so that the former can be shared between multiple threads * added SharedContext object for hosting information to be shared between solving threads * added shareable weight constraints * updated clause representation and added a shared clause constraint * splitted binary-/ternary implication graph into shared read-only static and fine-grained lock-protected dynamic part * implemented lock-free MultiQueue as first concrete nogood distributor (passive, global distribution) * implemented linear-time recursive-strengthen algorithm * switched to new version of ProgramOptions library * added support for "tagged" knowledge, i.e. nogoods tagged with an initial assumption * separated local (solver & search related) from global (enumeration & preprocessing) options in ClaspFacade * implemented more cache-efficient left_right_sequence for storing and distinguishing between clause and general watches * added (hidden) option "--dfrac" to set fraction of nogoods to delete on reduction * added new deletion algorithms and hidden option "--dalgo" for selecting between them * added hidden option "--dscore" for selecting between different nogood activity scoring schemes * added (hidden) option "--berk-once" for switching between multiset and set-based scoring in BerkMin clasp 1.3.6: Friday, 19th November 2010 * added missing copyright information to tests and examples * fixed a bug in preprocessing of weight rules where only literals but not their weights were swapped * fixed: lookahead accessed unitialized memory in incremental setting (concerns iclingo only) * fixed: inner-outer restart sequence always used hard-coded grow-factor clasp 1.3.5: Friday, 24th September 2010 * Removed warning for minimization under projection if safe * fixed inconsequent output format in time and statistics output * fixed bug in output of choice rules with empty head * fixed: truth-value of complementary eq-atom not correctly set * fixed: SAT-preprocessor must not reuse clause ids from previous incremental steps clasp 1.3.4: Monday, 14th June 2010 * moved claspre functionality to clasp (run configure with "--with-claspre" to enable it) * added "--search-limit" to limit search to a certain number of conflicts or restarts * calling clasp with "--stats=2" now prints jump statistics * long loop nogoods are now replaced with decision sequence if the latter is considerably shorter * sat-based preprocessing is now again enabled by default if input format is dimacs or OPB * fixed: option "--rand-prob" not always correctly parsed * fixed: lookahead not correctly initialized in incremental setting (only concerns iclingo) * fixed: enumerators not always correctly terminated when solving under assumptions * fixed: sat-output failed to '0'-terminate models * fixed: "--opt-value" did not work with negative numbers * simplified some code to avoid internal compiler error in gcc-3.4.3 clasp 1.3.3: Thursday, 1st April 2010 (April Fools' Day) * added "--trans-ext=card" and "--trans-ext=integ" for transforming cardinality rules resp. extended integrity constraints * added "--lemma-out=" and "--lemma-in=" for writing lemmas to resp. reading lemmas from * clasp now prints suboptimal models in PB-mode if called with "--verbosity=2" * added more timing statistics * application now reports actual average size of learnt lemmas instead of average contracted size * fixed: "--del=no" did not fully disable nogood deletion * fixed: "--opt-value" not checked against initial sum of minimize constraint * fixed: dimacs parser must not assign undefined literals to false if more than one model is requested * fixed: possible double-deletion in option "--pre" * fixed: unfounded set checker sometimes too lazy w.r.t heads of recursive extended rules * fixed a minor bug in eq-preprocessing * changed some code to avoid code generation bug in Visual C++ 2008 x64 see: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=526921 clasp 1.3.2: Friday, 15th January 2010 * fixed a 64-bit portability problem; clasp should now also run under Mac OS X 10.6 * fixed option "--pre" * fixed: SAT-preprocessor not correctly initialized on SAT-problems with more than 4 Mio. clauses clasp 1.3.1: Tuesday, 8th December 2009 * changed some internal interface to simplify integration of clasp in clingo/iclingo/clingcon * fixed a couple of bugs in the eq-preprocessing * fixed a bug in transformation of weight rules in incremental setting * fixed a crash bug in experimental "--backprop" preprocessor * fixed a bug that made clasp exit with code S_UNKNOWN (0) instead of S_UNSAT (20) on unsat problems (computation was correct, though) * fixed a command-line problem: option "--recursive-str" wrongly required an argument * fixed a small problem in PB-frontend that led to wrong optima clasp 1.3.0: Tuesday, 20th October 2009 * added an OPB front-end for solving linear Pseudo-Boolean constraint problems and removed switch "--dimacs": the input format (Smodels-input, dimacs, or OPB) is now automatically detected * added switch "--opt-ignore" and "--opt-heu" for ignoring optimize statements during search, resp. for setting the preferred value of literals occurring in minimize statements to false * added switch "--estimate" for initializing size of learnt DB based on estimated problem complexity * added switch "--reset-restart" for resetting restart schedule after each model found * added switch "--asp09" for enabling ASP'09 competition output format * added switch "--pre" for only printing preprocessed program * added switch "--backprop" for enabling backpropagation in ASP-preprocessor. Note: EXPERIMENTAL FEATURE * added option "--time-limit=" for setting a solving time limit of seconds * added option "--verbose=" for controlling status messages, where "--verbose=0" disables all status messages "--verbose=1" is the default and prints basic status information "--verbose=2" prints more status messages * option "--quiet" no longer controls status messages; it only disables printing of models * replaced option "--lookback=" with switch "--no-lookback" * option "--save-progress" now takes an int to enable progress saving only on jumps >= > 0 * default heuristic now disables MOMs-based top-level heuristic on large problems * removed auto_lookahead option * internal: added better interfaces for users of clasp library (iClingo, Clingcon, ...) * fixed an optimization that violated gcc's strict aliasing rules and could led to crashes * fixed a bug in the interplay of projective enumeration and sat-preprocessing that could led to the enumeration of duplicate models (w.r.t the projection variables) * fixed two bugs w.r.t optimization: first, clasp sometimes reported unknown optimum although last model was optimal. Second, reported optima for minimize statements containing facts were too low (optimality of models was correct, though) * fixed a lookahead bug which occurred only together with sat-preprocessing * fixed a small glitch in the recursive nogood minimization (switch "--recursive-str") clasp 1.2.1: Tuesday, 14th April 2009 * fixed a crash bug in handling of weight rules with bound 0 (introduced in 1.2.0) * added warning for minimization under projection * reverted behaviour of "--number" to pre 1.2.0, i.e. "--number" is again considered during optimization/computation of consequences * removed spurious warning when "--number" is not explicitly set on optimization * disabled printing of cautious consequences and optimization for UNSAT problems * clasp now also prints current optimum on interrupt clasp 1.2.0: Tuesday, 10th March 2009 * added "--project" for enabling projective enumeration * added "--solution-recording" for enabling alternative enumeration mode based on (solution) nogoods * added "--restart-on-model" for restarting search after each model (randomize enumeration) * changed "--initial-lookahead" to "--initial-lookahead=", where gives the number of choices to be selected by lookahead. If 0, lookahead is only used during preprocessing. * removed "--opt-restart", which is now superseded by "--restart-on-model" * added support for minimization during consequence computation * added new (platform specific) timer which won't overflow after merely 36 minutes * improved algorithm for handling recursive weight constraints * fixed a bug where B+ atoms were falsely removed during preprocessing * fixed a crash bug where clasp created bogus minimize statements for trivially UNSAT programs * fixed a bug in the unfounded set checker where multiple SCCs were not always handled correctly (bug was introduced in version 1.1.0) * fixed ProgramBuilder::writeProgram so that it now correctly writes integrity constraints (internal) clasp 1.1.3: Monday, 24th November 2008 * fixed handling of zero weighted atoms in minimize statements * fixed a bug that caused "--deletion=no" to constantly delete all learnt nogoods clasp 1.1.2: Saturday, 25th October 2008 * fixed a bug in the unfounded set checker (bug introduced in version 1.1.0) clasp 1.1.1: Monday, 13th October 2008 * revised option names, help text, and error messages * fixed a bug in the preprocessing/simplification of weight rules * fixed several bugs in the handling of incremental programs clasp 1.1.0: Thursday, 31th July 2008 * added "--sat-prepro" for SatElite-like preprocessing * improved eq-Preprocessing and updated "--eq" to reflect new iterative algorithm * added "--cautious" and "--brave" for cautious resp. brave reasoning * added new optimization mode "--opt-rand": similar to optimize-one but restarts after each enumerated model * added "--local-restarts" for local restarts as described in "Local Restarts" by Ryvchin and Strichman * added new inner-outer restart strategy from PicoSat; quadratic-scheme remains default for now * added "--expensiveccm" for expensive conflict clause minimization a la MiniSat; old Beame-scheme remains default for now * replaced old VSIDS heuristic with MiniSat-like VSIDS heuristic * changed growth strategy of learnt db * changed default value of "--contraction" to 250 * added support for incremental program update (internal) clasp 1.0.5: Monday, 31th December 2007 * added "--minimization=all" for conflict clause minimization over all antecedent types * changed default of "--minimization" from "bin" to "all". * added "--save-progress" for RSat-like progress saving * added "--optimize-value" for setting initial value(s) of optimize function * optimized implementation of cardinality-/weight-rules * simplified and improved implementation of ProgramBuilder and preprocessing * unfounded set checker is now also backtrack-free for extended rules * if "--rand-watches" is not used, watches in clauses are initialized to the two least watched literals * fixed a bug regarding lookahead: if lookahead was not used as heuristic, literal dependencies were not cleared; failed-literal detection skipped literals and thus did not always find all conflicts. * fixed a bug that led to wrong answers/crashes if "loops=no" was used * fixed a bug in preprocessing of minimize rules clasp 1.0.4: Wednesday, 22th August 2007 (updated: 24th August 2007) * improved equivalence-preprocessing w.r.t bodies of size > 1 and slightly decreased memory usage * improved look-back heuristics * changed default value of "--trans-ext" to "no", i.e. extended rules are now handled natively by default * simplified output and added "--stats" for enabling printing of extended statistics * implemented non-recursive version of Tarjan's SCC algorithm to prevent stack overflows on large SCCs * fixed another bug in handling of minimize rules * fixed a bug in the command-line interface that led to a crash when an unknown heuristic was given * fixed a bug concerning preprocessing/simplification of weight rules * 08/24/2007: fixed a bug in preprocessing of cardinality/weight rules containing duplicate literals * 10/25/2007: fixed a bug in preprocessing of satisfied bodies * 10/27/2007: fixed a bug where weight constraints were inadvertently handled as cardinality constraints whenever the second weight equaled 1 * 11/09/2007: fixed a bug in preprocessing of unsupported bodies clasp 1.0.3: Monday, 16th July 2007 * added a new parameter "no" to "--loops" which disables learning of loop formulas * improved performance of the equivalence-preprocessing algorithm on certain inputs * adapted lookahead so that it can distinguish equivalent variables * fixed a bug in the dimacs front-end that led to incorrect results on certain inputs * if "--loops=shared" was used, learnt loop formulas were not added to the learnt db and thus not subject to nogood deletion * fixed a bug that led to an infinite loop on certain optimization problems (bug was introduced in version 1.0.2) * added signal handler to intercept standard signals like SIGTERM clasp 1.0.2: Friday, 15th June 2007 * added "--eq" for equivalence-based preprocessing; added "--eq" to default command line * "--contraction" expects threshold length for dynamic compression of long learnt clauses (default: 60) * added a second (optional) grow factor to "--deletion" that is applied after every reduction * added "--reduce-on-restart" that removes some of the learnt nogoods on every restart * added "--optimize" for computing either one or all optimal solutions * fixed a bug that led to a crash when "--evaluate-loops=false" was used together with the default heuristic * fixed a bug that led to a crash on certain problems when lookahead was used in lookback mode clasp 1.0.1: Wednesday, 28th March 2007 * some fixes to make clasp compile on gcc 4.1 and gcc 4.2 * fixed a bug in the RNG that led to array-out-of-bounds accesses using certain standard library implementations * fixed a bug in the (native) handling of constraint-rules - clasp treated their bodies as sets and spuriously removed duplicate atoms * fixed a bug in the handling of compute-statements - clasp failed to produce a conflict if the compute-statement forced an unsupported atom to be true. clasp 1.0: Wednesday, 7th March 2007 * added native support for extended rules (disabled by default) * added support for optimize statements * added "--dimacs" for reading CNF-problems in dimacs-format * added "--contraction": dynamic clause compression for very long learnt clauses * added "--minimize": (weak) conflict clause minimization * added "--lookahead" for (configurable) failed-literal-detection * added "--rand-watches" for random initialization of watches * added "--rand-prop" for support of occasional random-choices * added "--supp-models" for computation of supported models * added "--bounded-restarts" for allowing (bounded) restarts afer solution was found * new and more dynamic VSIDS heuristic * new smodels-like lookahead heuristic * changed nogood deletion heuristic * removed -s option (replaced with --initial-lookahead) * renamed --no-learn option (now: --lookback=no) clasp Asp-Comp: Revision: Wednesday, 20th December 2006 * scaled-down version for the ASP-competition clasp RC4: Wednesday, 25th October 2006 * added new restart strategies * addad a randomization strategy similar to satzoo's "Burst of random variable orders" * added an option to initialize the random number generator * fixed bug in LparseReader that caused an infinite loop on bad input * fixed implementation of BerkMin heuristic * fixed potential memory-leak in clause deletion code clasp RC3: Friday, 29th September 2006 * transformation of extended rules to normal rules * some low-level stuff to improve performance clasp RC2: Monday, 19th June 2006 * version produced for paper * major bug fixes clasp RC1: Friday, 16th June 2006 * initial version clasp-3.1.4/CMakeLists.txt0000644000404600007640000000107112632266302015070 0ustar kaufmanncoolscmake_minimum_required(VERSION 2.6) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/tools") project(clasp) find_package(TBB) include_directories (libclasp libprogram_opts) if(NOT TBB_FOUND) MESSAGE (STATUS "TBB not found. Building without threads.") add_definitions( -DWITH_THREADS=0 ) else(NOT TBB_FOUND) MESSAGE (STATUS "TBB found. Building with threads.") add_definitions( -DWITH_THREADS=1 ) link_directories(${TBB_LIBRARY_DIRS}) endif(NOT TBB_FOUND) add_subdirectory(libclasp) add_subdirectory(libprogram_opts) add_subdirectory(app) clasp-3.1.4/COPYING0000644000404600007640000004310312632266302013365 0ustar kaufmanncools GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. clasp-3.1.4/libprogram_opts/0000755000404600007640000000000012632272507015540 5ustar kaufmanncoolsclasp-3.1.4/libprogram_opts/Makefile0000644000404600007640000000220512632266302017173 0ustar kaufmanncoolsSHELL ?= /bin/sh AR ?= ar CXX ?= g++ BUILD_DIR ?= . ROOT_DIR ?= . CXXFLAGS ?= -O3 -DNDEBUG FLAGS ?= ifneq ($(FLAGS),) -include $(FLAGS) endif INCLUDE := -I $(ROOT_DIR) ALL_CXXFLAGS := -W -Wall $(INCLUDE) $(CXXFLAGS) TARGET := $(BUILD_DIR)/lib/libprogram_opts.a SOURCES := $(patsubst $(ROOT_DIR)/src/%.cpp,%.cpp,$(wildcard $(ROOT_DIR)/src/*.cpp)) DEPS := $(patsubst %.cpp,$(BUILD_DIR)/%.dep, $(SOURCES)) OBJECTS := $(patsubst %.cpp,$(BUILD_DIR)/%.o, $(SOURCES)) vpath %.cpp $(ROOT_DIR)/src vpath %.h $(ROOT_DIR)/program_opts $(TARGET): $(FLAGS) $(DEPS) $(OBJECTS) $(AR) cvrs $(TARGET) $(OBJECTS) ifneq ($(MAKECMDGOALS),clean) -include $(DEPS) endif $(BUILD_DIR)/%.dep: %.cpp $(FLAGS) $(CXX) $(ALL_CXXFLAGS) -MT $(BUILD_DIR)/$*.o -MM $< > $@ $(BUILD_DIR)/%.o: %.cpp $(FLAGS) $(CXX) $(ALL_CXXFLAGS) -c $< -o $@ .PHONY: clean ifeq ($(findstring Windows,$(OS)),) clean: @$(RM) $(TARGET) @$(RM) $(OBJECTS) @$(RM) $(DEPS) else RM := del /F /Q clean: @$(RM) $(subst /,\,$(TARGET)) 2>nul @$(RM) $(subst /,\,$(OBJECTS)) 2>nul @$(RM) $(subst /,\,$(DEPS)) 2>nul endif clasp-3.1.4/libprogram_opts/CMakeLists.txt0000644000404600007640000000027612632266302020301 0ustar kaufmanncoolsfile(GLOB LIBOPTS_SRC src/*.cpp) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) add_library(libprogram_opts STATIC ${LIBOPTS_SRC}) clasp-3.1.4/libprogram_opts/src/0000755000404600007640000000000012632272507016327 5ustar kaufmanncoolsclasp-3.1.4/libprogram_opts/src/program_options.cpp0000644000404600007640000007313312632266302022260 0ustar kaufmanncools// // Copyright (c) Benjamin Kaufmann 2004 // // This is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This file is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // // NOTE: ProgramOptions is inspired by Boost.Program_options // see: www.boost.org/libs/program_options // #ifdef _MSC_VER #pragma warning (disable : 4786) #pragma warning (disable : 4503) #pragma warning (disable : 4996) #endif #include #include #include #include #include #include // for op<< #include // for CfgFileParser #include // std::sort #include #include #include using namespace std; namespace ProgramOptions { /////////////////////////////////////////////////////////////////////////////// // DefaultFormat /////////////////////////////////////////////////////////////////////////////// std::size_t DefaultFormat::format(std::vector& buf, const Option& o, std::size_t maxW) { buf.clear(); size_t bufSize = std::max(maxW, o.maxColumn()) + 3; const char* arg= o.argName(); const char* np = ""; const char* ap = ""; if (o.value()->isNegatable()) { if (!*arg) { np = "[no-]"; } else { ap = "|no"; bufSize += strlen(ap); } } buf.resize(bufSize); char* buffer = &buf[0]; size_t n = sprintf(buffer, " --%s%s", np, o.name().c_str()); if (o.value()->isImplicit() && *arg) { n += sprintf(buffer+n, "[=%s%s]", arg, ap); } if (o.alias()) { n += sprintf(buffer+n, ",-%c", o.alias()); } if (!o.value()->isImplicit()) { n += sprintf(buffer+n, "%c%s%s", (!o.alias()?'=':' '), arg, ap); } if (n < maxW) n += sprintf(buffer+n, "%-*.*s", int(maxW-n), int(maxW-n), " "); assert(n <= bufSize); return n; } std::size_t DefaultFormat::format(std::vector& buf, const char* desc, const Value& val, std::size_t) { std::size_t minS = strlen(desc); const char* temp = 0; if (!desc) desc = ""; buf.clear(); buf.reserve(minS+2); buf.push_back(':'); buf.push_back(' '); for (const char* look;; ++desc) { look = desc; while (*look && *look != '%') { ++look; } if (look != desc) { buf.insert(buf.end(), desc, look); } if (!*look++ || !*look) break; else if (*look == 'D') { temp = val.defaultsTo(); } else if (*look == 'A') { temp = val.arg(); } else if (*look == 'I') { temp = val.implicit(); } else { buf.push_back(*look); } if (temp) { buf.insert(buf.end(), temp, temp + strlen(temp)); } desc = look; temp = 0; } buf.push_back('\n'); return buf.size(); } std::size_t DefaultFormat::format(std::vector& buffer, const OptionGroup& grp) { buffer.clear(); if (grp.caption().length()) { buffer.reserve(grp.caption().length() + 4); buffer.push_back('\n'); buffer.insert(buffer.end(), grp.caption().begin(), grp.caption().end()); buffer.push_back(':'); buffer.push_back('\n'); buffer.push_back('\n'); } return buffer.size(); } void OstreamWriter::write(const std::vector& buf, std::size_t n) { if (n) { out.write(&buf[0], n); } } void StringWriter::write(const std::vector& buf, std::size_t n) { if (n) { out.append(&buf[0], n); } } void FileWriter::write(const std::vector& buf, std::size_t n) { if (n) { fwrite(&buf[0], 1, n, out); } } /////////////////////////////////////////////////////////////////////////////// // class Value /////////////////////////////////////////////////////////////////////////////// Value::Value(byte_t flagSet, State initial) : state_(static_cast(initial)) , flags_(flagSet) , descFlag_(0) , optAlias_(0) { desc_.value = 0; } Value::~Value() { if (descFlag_ == desc_pack) { ::operator delete(desc_.pack); } } const char* Value::arg() const { const char* x = desc(desc_name); if (x) return x; return isFlag() ? "" : ""; } Value* Value::desc(DescType t, const char* n) { if (n == 0) return this; if (t == desc_implicit) { setProperty(property_implicit); if (!*n) return this; } if (descFlag_ == 0 || descFlag_ == t) { desc_.value = n; descFlag_ = static_cast(t); return this; } if (descFlag_ != desc_pack) { const char* oldVal = desc_.value; unsigned oldKey = descFlag_ >> 1u; desc_.pack = (const char**)::operator new(sizeof(const char*[3])); desc_.pack[0]= desc_.pack[1] = desc_.pack[2] = 0; descFlag_ = desc_pack; desc_.pack[oldKey] = oldVal; } desc_.pack[t>>1u] = n; return this; } const char* Value::desc(DescType t) const { if (descFlag_ == t || descFlag_ == desc_pack) { return descFlag_ == t ? desc_.value : desc_.pack[t >> 1u]; } return 0; } const char* Value::implicit() const { if (!hasProperty(property_implicit)) return 0; const char* x = desc(desc_implicit); return x ? x : "1"; } bool Value::parse(const std::string& name, const std::string& value, State st) { if (!value.empty() || !isImplicit()) return state(doParse(name, value), st); const char* x = implicit(); assert(x); return state(doParse(name, x), st); } /////////////////////////////////////////////////////////////////////////////// // class Option /////////////////////////////////////////////////////////////////////////////// Option::Option(const string& longName, char alias, const char* desc, Value* v) : name_(longName) , description_(desc ? desc : "") , value_(v) { assert(v); assert(!longName.empty()); value_->alias(alias); } Option::~Option() { delete value_; } std::size_t Option::maxColumn() const { std::size_t col = 4 + name_.size(); // --name if (alias()) { col += 3; // ,-o } std::size_t argN = strlen(argName()); if (argN) { col += (argN + 1); // =arg if (value()->isImplicit()) { col += 2; // [] } if (value()->isNegatable()) { col += 3; // |no } } else if (value()->isNegatable()) { col += 5; // [no-] } return col; } bool Option::assignDefault() const { if (value()->defaultsTo() != 0 && value()->state() != Value::value_defaulted) { return value()->parse(name(), value()->defaultsTo(), Value::value_defaulted); } return true; } /////////////////////////////////////////////////////////////////////////////// // class OptionGroup /////////////////////////////////////////////////////////////////////////////// OptionGroup::OptionGroup(const std::string& caption, DescriptionLevel hl) : caption_(caption), level_(hl) {} OptionGroup::~OptionGroup() { } OptionInitHelper OptionGroup::addOptions() { return OptionInitHelper(*this); } void OptionGroup::addOption(std::auto_ptr