diff --git a/Makefile.in b/Makefile.in index 838224c9a..f37e8f5c7 100755 --- a/Makefile.in +++ b/Makefile.in @@ -677,6 +677,7 @@ mycb: $(srcdir)/mycb.c $(CC) $(CFLAGS) $(srcdir)/mycb.c -o mycb all: startup.yss + @ENABLE_GECODE@ @INSTALL_DLLS@ (cd library/gecode; $(MAKE)) @INSTALL_DLLS@ (cd library/lammpi; $(MAKE)) @INSTALL_MATLAB@ (cd library/matlab; $(MAKE)) @INSTALL_DLLS@ (cd library/matrix; $(MAKE)) @@ -749,6 +750,7 @@ install_unix: startup.yss libYap.a @INSTALL_DLLS@ (cd library/rltree; $(MAKE) install) @INSTALL_DLLS@ (cd library/system; $(MAKE) install) @INSTALL_DLLS@ (cd library/tries; $(MAKE) install) + @ENABLE_GECODE@ @INSTALL_DLLS@ (cd library/gecode; $(MAKE) install) @ENABLE_CLIB@ @INSTALL_DLLS@ (cd packages/clib; $(MAKE) install) @ENABLE_HTTP@ @INSTALL_DLLS@ (cd packages/http; $(MAKE) install) @ENABLE_PLDOC@ @INSTALL_DLLS@ (cd packages/pldoc; $(MAKE) install) @@ -856,6 +858,7 @@ depend: $(HEADERS) $(C_SOURCES) clean: clean_docs rm -f *.o *~ *.BAK *.a + @ENABLE_GECODE@ @INSTALL_DLLS@ (cd library/gecode; $(MAKE) clean) @INSTALL_DLLS@ (cd library/lammpi; $(MAKE) clean) @INSTALL_MATLAB@ (cd library/matlab; $(MAKE) clean) @INSTALL_DLLS@ (cd library/matrix; $(MAKE) clean) diff --git a/configure b/configure index edc5facfc..4b26c5407 100755 --- a/configure +++ b/configure @@ -689,9 +689,7 @@ CPLINT_SHLIB_LD CPLINT_LDFLAGS CPLINT_CFLAGS CPLINT_LIBS -EGREP -GREP -CPP +ENABLE_GECODE INSTALL_INFO MPI_CC AR @@ -716,6 +714,10 @@ build DefTrailSpace DefStackSpace DefHeapSpace +PYTHON +EGREP +GREP +CPP C_PARSER_FLAGS C_INTERF_FLAGS GCC @@ -771,6 +773,7 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking +enable_gecode enable_tabling enable_or_parallelism enable_rational_trees @@ -1443,6 +1446,7 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-gecode install gecode library --enable-tabling support tabling --enable-or-parallelism support or-parallelism as: copy,sba,a-cow,threads --enable-rational-trees support infinite rational trees @@ -1661,52 +1665,6 @@ fi } # ac_fn_cxx_try_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1904,6 +1862,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -3709,6 +3713,480 @@ done + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +ac_fn_c_check_header_mongrel "$LINENO" "gecode/support/config.hpp" "ac_cv_header_gecode_support_config_hpp" "$ac_includes_default" +if test "x$ac_cv_header_gecode_support_config_hpp" = xyes; then : + have_gecode=yes +else + have_gecode=no +fi + + +use_gecode_default=no + +if test "$have_gecode" = yes; then + for ac_prog in python2.78 python +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON"; then + ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PYTHON="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON=$ac_cv_prog_PYTHON +if test -n "$PYTHON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 +$as_echo "$PYTHON" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON" && break +done +test -n "$PYTHON" || PYTHON="none" + + if test "$PYTHON" != none; then + use_gecode_default=yes + fi +else + PYTHON=none +fi +# Check whether --enable-gecode was given. +if test "${enable_gecode+set}" = set; then : + enableval=$enable_gecode; use_gecode="$enableval" + if test "$use_gecode" = yes; then + if test "$have_gecode" = no; then + as_fn_error $? "cannot enable gecode: gecode library not found" "$LINENO" 5 + fi + if test "$PYTHON" = none; then + as_fn_error $? "cannot enable gecode: python not found" "$LINENO" 5 + fi + fi +else + use_gecode=$use_gecode_default +fi + + # Check whether --enable-tabling was given. if test "${enable_tabling+set}" = set; then : enableval=$enable_tabling; tabling="$enableval" @@ -5112,8 +5590,7 @@ then then if test "$target_win64" = yes then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lws2_32" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lws2_32" >&5 $as_echo_n "checking for main in -lws2_32... " >&6; } if ${ac_cv_lib_ws2_32_main+:} false; then : $as_echo_n "(cached) " >&6 @@ -5895,6 +6372,372 @@ else #include #include +int +main () +{ +SQLHENV henv; + SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); +======= +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f + + +$as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h + + LIBS="$LIBS -lreadline -lncurses" + +else + if test "x$with_readline" != xcheck; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "--with-readline was given, but test for readline failed +See \`config.log' for more details" "$LINENO" 5; } + fi + +fi + +fi +if test "$yap_cv_gmp" != "no" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 +$as_echo_n "checking for pthread_create in -lpthread... " >&6; } +if ${ac_cv_lib_pthread_pthread_create+:} false; then : +======= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgmp" >&5 +$as_echo_n "checking for main in -lgmp... " >&6; } +if ${ac_cv_lib_gmp_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgmp $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_gmp_main=yes +else + ac_cv_lib_gmp_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } +if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : +======= +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gmp_main" >&5 +$as_echo "$ac_cv_lib_gmp_main" >&6; } +if test "x$ac_cv_lib_gmp_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGMP 1 +_ACEOF + + LIBS="-lgmp $LIBS" + +fi + +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : +======= + +if test "$yap_cv_yapr" != "no" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lR" >&5 +$as_echo_n "checking for main in -lR... " >&6; } +if ${ac_cv_lib_R_main+:} false; then : +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lR $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext +======= +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +<<<<<<< HEAD +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +======= +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_R_main=yes +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f +else + ac_cv_lib_R_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +<<<<<<< HEAD +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : +======= +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_R_main" >&5 +$as_echo "$ac_cv_lib_R_main" >&6; } +if test "x$ac_cv_lib_R_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBR 1 +_ACEOF + + LIBS="-lR $LIBS" + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lRmath" >&5 +$as_echo_n "checking for main in -lRmath... " >&6; } +if ${ac_cv_lib_Rmath_main+:} false; then : +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lRmath $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +<<<<<<< HEAD + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +======= + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_Rmath_main=yes +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f +else + ac_cv_lib_Rmath_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Rmath_main" >&5 +$as_echo "$ac_cv_lib_Rmath_main" >&6; } +if test "x$ac_cv_lib_Rmath_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRMATH 1 +_ACEOF + +<<<<<<< HEAD +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +======= + LIBS="-lRmath $LIBS" + +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f +fi + +fi + + +<<<<<<< HEAD +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : +======= +if test "$yap_cv_myddas" != "no" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmysqlclient" >&5 +$as_echo_n "checking for main in -lmysqlclient... " >&6; } + if ${yap_cv_mysql+:} false; then : +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +MYSQL *conn; + conn = mysql_init(NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + yap_cv_mysql=yes +else + yap_cv_mysql=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_mysql" >&5 +$as_echo "$yap_cv_mysql" >&6; } + if test "$yap_cv_mysql" = yes + then + YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL" + LIBS="$LIBS -L${yap_cv_myddas}/lib/mysql -lmysqlclient " + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lodbc" >&5 +$as_echo_n "checking for main in -lodbc... " >&6; } + if ${yap_cv_odbc+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include + int main () { @@ -5976,396 +6819,7 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 -$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } -if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPTHREAD 1 -_ACEOF - - LIBS="-lpthread $LIBS" - -fi - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi +<<<<<<< HEAD # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ @@ -6375,16 +6829,20 @@ do : ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : +======= +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } +if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : +>>>>>>> d4d4dbaddf15563b573697caec6fd7c63dfcbf2f cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_LIBPTHREAD 1 _ACEOF + LIBS="-lpthread $LIBS" + fi -done - - -for ac_header in pthread.h + for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : @@ -6426,6 +6884,13 @@ fi CMFLAGS=-fpic CIFLAGS=-I. +if test "$use_gecode" = no; then + ENABLE_GECODE="@# " +else + ENABLE_GECODE="" +fi + + if test "$use_chr" = no; then ENABLE_CHR="@# " elif test -e "$srcdir"/packages/chr/Makefile.in; then @@ -10061,6 +10526,11 @@ ac_config_files="$ac_config_files packages/CLPBN/clpbn/bp/Makefile" fi +if test "$ENABLE_GECODE" = ""; then +ac_config_files="$ac_config_files library/gecode/Makefile" + +fi + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -10811,6 +11281,7 @@ do "packages/swi-minisat2/C/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/C/Makefile" ;; "packages/YapR/Makefile") CONFIG_FILES="$CONFIG_FILES packages/YapR/Makefile" ;; "packages/CLPBN/clpbn/bp/Makefile") CONFIG_FILES="$CONFIG_FILES packages/CLPBN/clpbn/bp/Makefile" ;; + "library/gecode/Makefile") CONFIG_FILES="$CONFIG_FILES library/gecode/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.in b/configure.in index de5f38bb9..eb1a5a2b3 100644 --- a/configure.in +++ b/configure.in @@ -56,6 +56,31 @@ AC_SUBST(GCC) AC_SUBST(C_INTERF_FLAGS) AC_SUBST(C_PARSER_FLAGS) +dnl Gecode support +AC_CHECK_HEADER(gecode/support/config.hpp, + have_gecode=yes, have_gecode=no) +use_gecode_default=no +AC_SUBST(PYTHON) +if test "$have_gecode" = yes; then + AC_CHECK_PROGS(PYTHON, [python2.78 python], [none]) + if test "$PYTHON" != none; then + use_gecode_default=yes + fi +else + PYTHON=none +fi +AC_ARG_ENABLE(gecode, + [ --enable-gecode install gecode library], + [use_gecode="$enableval" + if test "$use_gecode" = yes; then + if test "$have_gecode" = no; then + AC_MSG_ERROR([cannot enable gecode: gecode library not found]) + fi + if test "$PYTHON" = none; then + AC_MSG_ERROR([cannot enable gecode: python not found]) + fi + fi], use_gecode=$use_gecode_default) + AC_ARG_ENABLE(tabling, [ --enable-tabling support tabling ], tabling="$enableval", tabling=no) @@ -747,6 +772,13 @@ fi CMFLAGS=-fpic CIFLAGS=-I. +if test "$use_gecode" = no; then + ENABLE_GECODE="@# " +else + ENABLE_GECODE="" +fi +AC_SUBST(ENABLE_GECODE) + if test "$use_chr" = no; then ENABLE_CHR="@# " elif test -e "$srcdir"/packages/chr/Makefile.in; then @@ -2225,5 +2257,9 @@ if test "$ENABLE_CLPBN_BP" = ""; then AC_CONFIG_FILES([packages/CLPBN/clpbn/bp/Makefile]) fi +if test "$ENABLE_GECODE" = ""; then +AC_CONFIG_FILES([library/gecode/Makefile]) +fi + AC_OUTPUT() diff --git a/library/gecode/DOC.txt b/library/gecode/DOC.txt new file mode 100644 index 000000000..3ca6d3888 --- /dev/null +++ b/library/gecode/DOC.txt @@ -0,0 +1,167 @@ +USING THE GECODE MODULE +======================= + +:- use_module(gecode). +or +:- use_module(library(gecode)). +if it is installed as a library module + +CREATING A SPACE +================ + + Space := space + +CREATING VARIABLES +================== + +Unlike in Gecode, variable objects are not bound to a specific Space. Each one +actually contains an index with which it is possible to access a Space-bound +Gecode variable. Variables can be created using the following expressions: + + IVar := intvar(Space,SPEC...) + BVar := boolvar(Space) + SVar := setvar(Space,SPEC...) + +where SPEC... is the same as in Gecode. For creating lists of variables use +the following variants: + + IVars := intvars(Space,N,SPEC...) + BVars := boolvars(Space,N,SPEC...) + SVars := setvars(Space,N,SPEC...) + +where N is the number of variables to create (just like for XXXVarArray in +Gecode). Sometimes an IntSet is necessary: + + ISet := intset([SPEC...]) + +where each SPEC is either an integer or a pair (I,J) of integers. An IntSet +describes a set of ints by providing either intervals, or integers (which stand +for an interval of themselves). It might be tempting to simply represent an +IntSet as a list of specs, but this would be ambiguous with IntArgs which, +here, are represented as lists of ints. + +CONSTRAINTS AND BRANCHINGS +========================== + +all constraint and branching posting functions are available just like in +Gecode. Wherever a XXXArgs or YYYSharedArray is expected, simply use a list. +At present, there is no support for minimodel-like constraint posting. +Constraints and branchings are added to a space using: + + Space += CONSTRAINT + Space += BRANCHING + +For example: + + Space += rel(X,'IRT_EQ',Y) + +arrays of variables are represented by lists of variables, and constants are +represented by atoms with the same name as the Gecode constant +(e.g. 'INT_VAR_SIZE_MIN'). + +SEARCHING FOR SOLUTIONS +======================= + + SolSpace := search(Space) + +This is a backtrackable predicate that enumerates all solution spaces +(SolSpace). + +EXTRACTING INFO FROM A SOLUTION +=============================== + +An advantage of non Space-bound variables, is that you can use them both to +post constraints in the original space AND to consult their values in +solutions. Below are methods for looking up information about variables. Each +of these methods can either take a variable as argument, or a list of +variables, and returns resp. either a value, or a list of values: + + Val := assigned(Space,X) + + Val := min(Space,X) + Val := max(Space,X) + Val := med(Space,X) + Val := val(Space,X) + Val := size(Space,X) + Val := width(Space,X) + Val := regret_min(Space,X) + Val := regret_max(Space,X) + + Val := glbSize(Space,V) + Val := lubSize(Space,V) + Val := unknownSize(Space,V) + Val := cardMin(Space,V) + Val := cardMax(Space,V) + Val := lubMin(Space,V) + Val := lubMax(Space,V) + Val := glbMin(Space,V) + Val := glbMax(Space,V) + Val := glb_ranges(Space,V) + Val := lub_ranges(Space,V) + Val := unknown_ranges(Space,V) + Val := glb_values(Space,V) + Val := lub_values(Space,V) + Val := unknown_values(Space,V) + +DISJUNCTORS +=========== + +Disjunctors provide support for disjunctions of clauses, where each clause is a +conjunction of constraints: + + C1 or C2 or ... or Cn + +Each clause is executed "speculatively": this means it does not affect the main +space. When a clause becomes failed, it is discarded. When only one clause +remains, it is committed: this means that it now affects the main space. + +Example: + +Consider the problem where either X=Y=0 or X=Y+(1 or 2) for variable X and Y +that take values in 0..3. + + Space := space, + [X,Y] := intvars(Space,2,0,3), + +First, we must create a disjunctor as a manager for our 2 clauses: + + Disj := disjunctor(Space), + +We can now create our first clause: + + C1 := clause(Disj), + +This clause wants to constrain X and Y to 0. However, since it must be +executed "speculatively", it must operate on new variables X1 and Y1 that +shadow X and Y: + + [X1,Y1] := intvars(C1,2,0,3), + C1 += forward([X,Y],[X1,Y1]), + +The forward(...) stipulation indicates which global variable is shadowed by +which clause-local variable. Now we can post the speculative clause-local +constraints for X=Y=0: + + C1 += rel(X1,'IRT_EQ',0), + C1 += rel(Y1,'IRT_EQ',0), + +We now create the second clause which uses X2 and Y2 to shadow X and Y: + + C2 := clause(Disj), + [X2,Y2] := intvars(C2,2,0,3), + C2 += forward([X,Y],[X2,Y2]), + +However, this clause also needs a clause-local variable Z2 taking values 1 or +2 in order to post the clause-local constraint X2=Y2+Z2: + + Z2 := intvar(C2,1,2), + C2 += linear([-1,1,1],[X2,Y2,Z2],'IRT_EQ',0), + +Finally, we can branch and search: + + Space += branch([X,Y],'INT_VAR_SIZE_MIN','INT_VAL_MIN'), + SolSpace := search(Space), + +and lookup values of variables in each solution: + + [X_,Y_] := val(SolSpace,[X,Y]). diff --git a/library/gecode/Makefile.in b/library/gecode/Makefile.in new file mode 100644 index 000000000..71b7b074d --- /dev/null +++ b/library/gecode/Makefile.in @@ -0,0 +1,90 @@ +# +# default base directory for YAP installation +# (EROOT for architecture-dependent files) +# +prefix = @prefix@ +exec_prefix = @exec_prefix@ +ROOTDIR = $(prefix) +EROOTDIR = @exec_prefix@ +abs_top_builddir = @abs_top_builddir@ +# +# where the binary should be +# +BINDIR = $(EROOTDIR)/bin +# +# where YAP should look for libraries +# +LIBDIR=@libdir@ +YAPLIBDIR=@libdir@/Yap +# +# where YAP should look for architecture-independent Prolog libraries +# +SHAREDIR=$(ROOTDIR)/share +# +# +CXX=@CXX@ +CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include $(CPPFLAGS) +CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include $(CPPFLAGS) +# +# +# You shouldn't need to change what follows. +# +INSTALL=@INSTALL@ +INSTALL_DATA=@INSTALL_DATA@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +SHELL=/bin/sh +RANLIB=@RANLIB@ +srcdir=@srcdir@ +SO=@SO@ +#4.1VPATH=@srcdir@:@srcdir@/OPTYap +CWD=$(PWD) +# + +OBJS=gecode_yap.o +SOBJS=gecode_yap.@SO@ + +CODEGEN=$(srcdir)/code-generator.py +DISJUNCTOR = -DDISJUNCTOR +PYTHON = @PYTHON@ +export PYTHONPATH:=$(srcdir):$(PYTHONPATH) + +all: $(SOBJS) gecode.yap + +gecode_yap.o: \ + $(srcdir)/gecode_yap.cc \ + $(srcdir)/gecode-common.icc \ + gecode_yap_cc_impl_auto_generated.icc \ + gecode_yap_cc_init_auto_generated.icc \ + gecode_yap_cc_forward_auto_generated.icc \ + $(srcdir)/disjunctor.icc \ + $(srcdir)/disjunctor.hh + $(CXX) -c $(CXXFLAGS) $(DISJUNCTOR) -o $@ $< + +@DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o +@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@ + +gecode_yap_cc_init_auto_generated.icc: $(CODEGEN) + $(PYTHON) $< -t yap-cc-init -s $(srcdir) > $@ + +gecode_yap_cc_impl_auto_generated.icc: $(CODEGEN) + $(PYTHON) $< -t yap-cc-impl -s $(srcdir) > $@ + +gecode_yap_cc_forward_auto_generated.icc: $(CODEGEN) + $(PYTHON) $< -t yap-cc-forward -s $(srcdir) > $@ + +gecode_yap_auto_generated.yap: $(CODEGEN) + $(PYTHON) $< -t yap-prolog -s $(srcdir) > $@ + +gecode.yap: $(srcdir)/gecode_yap_hand_written.yap gecode_yap_auto_generated.yap + cat $^ > $@ + +.PHONY: all clean install + +clean: + -rm -f *.o *.so *~ *_auto_generated* gecode.yap *.pyc + +install: all + mkdir -p $(DESTDIR)$(YAPLIBDIR) + mkdir -p $(DESTDIR)$(SHAREDIR)/Yap + $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR) + $(INSTALL) gecode.yap $(DESTDIR)$(SHAREDIR)/Yap diff --git a/library/gecode/Makefile.sav b/library/gecode/Makefile.sav new file mode 100644 index 000000000..a2acd2056 --- /dev/null +++ b/library/gecode/Makefile.sav @@ -0,0 +1,34 @@ +CODEGEN=code-generator.py +DISJUNCTOR = -DDISJUNCTOR + +yap: gecode_yap.so gecode.yap + +gecode_yap.o: gecode_yap.cc gecode-common.icc \ + gecode_yap_cc_impl_auto_generated.icc \ + gecode_yap_cc_init_auto_generated.icc \ + gecode_yap_cc_forward_auto_generated.icc \ + disjunctor.icc disjunctor.hh + $(CXX) -Wall -ggdb -c -shared -fPIC $(DISJUNCTOR) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< + +gecode_yap.so: gecode_yap.o + $(CXX) -shared $(LDFLAGS) -o $@ $< -lgecodeint -lgecodeset -lgecodesearch + +gecode_yap_cc_init_auto_generated.icc: $(CODEGEN) + python $< -t yap-cc-init > $@ + +gecode_yap_cc_impl_auto_generated.icc: $(CODEGEN) + python $< -t yap-cc-impl > $@ + +gecode_yap_cc_forward_auto_generated.icc: $(CODEGEN) + python $< -t yap-cc-forward > $@ + +gecode_yap_auto_generated.yap: $(CODEGEN) + python $< -t yap-prolog > $@ + +gecode.yap: gecode_yap_hand_written.yap gecode_yap_auto_generated.yap + cat $^ > $@ + +.PHONY: yap + +clean: + -rm -f *.o *.so *~ *_auto_generated* gecode.yap diff --git a/library/gecode/code-generator.py b/library/gecode/code-generator.py new file mode 100644 index 000000000..acdc40479 --- /dev/null +++ b/library/gecode/code-generator.py @@ -0,0 +1,708 @@ +# -*- python -*- +#============================================================================== +# Copyright (C) 2011 by Denys Duchier +# +# 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 3 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, see . +#============================================================================== + +import re + +NOTICE_CC = """// -*- c++ -*- +//============================================================================= +// Copyright (C) 2011 by Denys Duchier +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by the +// Free Software Foundation, either version 3 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 Lesser General Public License +// along with this program. If not, see . +//============================================================================= +""" + +NOTICE_PROLOG="""%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= +""" + +def prolog_print_notice(): + print NOTICE_PROLOG + +def cc_print_notice(): + print NOTICE_CC + +class Type(object): + + DEFAULT = re.compile("""^(.+)=(.+)$""") + CONST = re.compile("""^const\\b(.+)$""") + UNSIGNED = re.compile("""^unsigned\\b(.+)$""") + REFERENCE = re.compile("""^(.+)&$""") + + def __init__(self, text): + if isinstance(text, Type): + self.clone_from(text) + return + text = text.strip() + m = self.DEFAULT.match(text) + if m: + self.default = m.group(2).strip() + text = m.group(1).strip() + else: + self.default = None + m = self.CONST.match(text) + if m: + self.const = True + text = m.group(1).strip() + else: + self.const = False + m = self.UNSIGNED.match(text) + if m: + self.unsigned = True + text = m.group(1).strip() + else: + self.unsigned = False + m = self.REFERENCE.match(text) + if m: + self.reference = True + text = m.group(1).strip() + else: + self.reference = False + self.type = text + + def __str__(self): + l = [] + if self.const: l.append("const ") + if self.unsigned: l.append("unsigned ") + l.append(self.type) + if self.reference: l.append("&") + if self.default is not None: + l.append("=") + l.append(self.default) + return ''.join(l) + + def clone_from(self, other): + self.const = other.const + self.unsigned = other.unsigned + self.type = other.type + self.reference = other.reference + self.default = other.default + + def clone(self): + return type(self)(self) + + +class Constraint(object): + + DECL = re.compile("""^([^(]+)\\b(\w+)\((.*)\);$""") + ARG = re.compile("""((?:[^,<(]|<[^>]*>|\([^)]*\))+),?""") + + def __init__(self, line): + if isinstance(line, Constraint): + self.clone_from(line) + return + line = line.strip() + m = self.DECL.match(line) + self.rettype = Type(m.group(1).strip()) + self.name = m.group(2) + argtypes = [] + for x in self.ARG.finditer(m.group(3).strip()): + argtypes.append(Type(x.group(1))) + self.argtypes = tuple(argtypes) + self.api = None + + def __str__(self): + l = [] + l.append(str(self.rettype)) + l.append(" ") + l.append(self.name) + sep = "(" + for x in self.argtypes: + l.append(sep) + sep = ", " + l.append(str(x)) + l.append(")") + if self.api is not None: + l.append(" -> ") + l.append(self.api) + l.append(";") + return ''.join(l) + + def clone_from(self, other): + self.rettype = other.rettype.clone() + self.name = other.name + self.argtypes = tuple(t.clone() for t in other.argtypes) + + def clone(self): + return type(self)(self) + + +COMMENT = re.compile("""^\\s*//.*$""") + +def load_decls(filename): + decls = [] + for line in open(filename): + line = line.strip() + if not line: continue + m = COMMENT.match(line) + if m: continue + decls.append(Constraint(line)) + return decls + +class DeclsLoader(object): + + def __init__(self, filename): + self.decls = load_decls(filename) + + def print_decls(self): + for con in self.decls: + print str(con) + +class PredGenerator(DeclsLoader): + + OMIT = ("DFA", # NOT YET SUPPORTED!!! + "TupleSet", # NOT YET SUPPORTED!!! + "VarBranchOptions", + "ValBranchOptions", + "TieBreakVarBranch", + "TieBreakVarBranchOptions", + "TieBreakVarBranch") + + def __init__(self, filename): + super(PredGenerator, self).__init__(filename) + self._change_home_to_space() + self._change_intsharedarray_to_intargs() + self._generate() + self._number() + + def _change_home_to_space(self): + for p in self.decls: + for t in p.argtypes: + if t.type=="Home": + t.type="Space" + + def _change_intsharedarray_to_intargs(self): + for p in self.decls: + for t in p.argtypes: + if t.type=="IntSharedArray": + t.type="IntArgs" + + def _generate(self): + # drop the constraints and optional arguments we can't handle + preds = [] + for con in self.decls: + if self._con_ok(con): + con = con.clone() + con.argtypes = tuple(self._drop_deco(t) for t in con.argtypes + if t.type not in self.OMIT) + preds.append(con) + # for each pred that has an argument with a default produce + # 2 preds (1 without, 1 with). repeat until all defaults have + # been removed. + again = True + while again: + preds_ = [] + again = False + for con in preds: + i = self._defaulted(con.argtypes) + if i is None: + preds_.append(con) + else: + again = True + before = con.argtypes[:i] + # without the default argument + # and therefore without the args that follow + con1 = con.clone() + con1.argtypes = before + preds_.append(con1) + # with the default argument (not default anymore) + con2 = con.clone() + arg = con.argtypes[i].clone() + arg.default=None + after = con.argtypes[i+1:] + con2.argtypes = before + (arg,) + after + preds_.append(con2) + preds = preds_ + self.preds = preds + + def _con_ok(self, con): + for t in con.argtypes: + if (t.type in self.OMIT) and (t.default is None): + return False + return True + + def _drop_deco(self, t): + # drop const, ref, and unsigned indications + t.const = False + t.reference = False + t.unsigned = False + return t + + def _defaulted(self, argtypes): + i = 0 + for x in argtypes: + if x.default is not None: + return i + i += 1 + return None + + def _number(self): + i = 1 + for x in self.preds: + x.api = "%s_%d" % (x.name,i) + i += 1 + + def print_preds(self): + for p in self.preds: + print str(p) + +class Cluster(object): + + def __init__(self, name, arity): + self.name = name + self.arity = arity + self.preds = [] + +# discriminating tree based on argument types +class DTree(object): + + def __init__(self, i, preds): + self.index = i + if len(preds) == 1 and len(preds[0].argtypes) == i: + self.is_leaf = True + self.pred = preds[0] + return + self.is_leaf = False + # i is the index of the current arg + # preds are the predicates to be indexed under this tree node + dispatch = {} + for p in preds: + t = p.argtypes[i] + d = dispatch.get(t.type, None) + if d is None: + d = [] + dispatch[t.type] = d + d.append(p) + self.subtrees = tuple((t2,DTree(i+1,p2)) + for t2,p2 in dispatch.iteritems()) + + def _generate_body(self, user_vars, lib_vars): + if self.is_leaf: + return PrologLiteral("gecode_constraint_%s(%s)" % (self.pred.api, ",".join(lib_vars))) + X = user_vars[self.index] + Y = lib_vars[self.index] + return self._generate_dispatch(0, user_vars, lib_vars) + + def _generate_dispatch(self, i, user_vars, lib_vars): + if i == len(self.subtrees): + return PrologLiteral("throw(gecode_argument_error)") + typ, dtree = self.subtrees[i] + idx = self.index + X = user_vars[idx] + Y = lib_vars[idx] + # hack for disjunctor support + if typ=="Space": + typ = "Space_or_Clause" + return PrologIF( + PrologLiteral("is_%s(%s,%s)" % (typ,X,Y)), + dtree._generate_body(user_vars, lib_vars), + self._generate_dispatch(i+1, user_vars, lib_vars)) + + def _cc_descriptors(self, name, argtypes): + if self.is_leaf: + return (CCDescriptor(name, argtypes, self.pred.api),) + descriptors = [] + for typ,dtree in self.subtrees: + descriptors.extend(dtree._cc_descriptors(name,(argtypes+(typ,)))) + return descriptors + +class YAPConstraintGeneratorBase(PredGenerator): + + def __init__(self, filename): + super(YAPConstraintGeneratorBase, self).__init__(filename) + self._classify() + self._dtreefy() + + # create clusters (predicate,arity) + def _classify(self): + clusters = {} + for pred in self.preds: + name = pred.name + arity = len(pred.argtypes) + key = (name,arity) + cluster = clusters.get(key, None) + if cluster is None: + cluster = Cluster(name, arity) + clusters[key] = cluster + cluster.preds.append(pred) + self.clusters = clusters + + # for each cluster, create a dtree + def _dtreefy(self): + dtrees = {} + for key, cluster in self.clusters.iteritems(): + dtree = DTree(0, cluster.preds) + dtrees[key] = dtree + self.dtrees = dtrees + + def _user_vars(self, arity): + return tuple(("X%d" % i) for i in range(arity)) + + def _lib_vars(self, arity): + return tuple(("Y%d" % i) for i in range(arity)) + +class YAPConstraintPrologGenerator(YAPConstraintGeneratorBase): + + def __init__(self, filename): + super(YAPConstraintPrologGenerator, self).__init__(filename) + + def _prolog_clauses(self): + clauses = [] + for (name, arity), dtree in self.dtrees.iteritems(): + user_vars = self._user_vars(arity) + lib_vars = self._lib_vars(arity) + head = "%s(%s)" % (name, ",".join(user_vars)) + body = dtree._generate_body(user_vars, lib_vars) + clause = PrologClause(head, body) + clauses.append(clause) + return clauses + + def generate(self): + out = OStream(sys.stdout) + for clause in self._prolog_clauses(): + clause.pp(out, 0) + +class YAPConstraintCCGenerator(YAPConstraintGeneratorBase): + + def __init__(self, filename): + super(YAPConstraintCCGenerator, self).__init__(filename) + + def _cc_descriptors(self): + descriptors = [] + for (name, arity), dtree in self.dtrees.iteritems(): + descriptors.extend(dtree._cc_descriptors(name,())) + return descriptors + + def generate_impl(self): + for d in self._cc_descriptors(): + d.generate_impl() + + def generate_init(self): + for d in self._cc_descriptors(): + d.generate_init() + +# output stream that keeps track of the current column +# to facilitate proper indentation + +import sys + +class OStream(object): + + def __init__(self, fd=sys.stdout): + self.file = fd + self.column = 0 + + def write(self, s): + reset = False + for x in s.split('\n'): + if reset: + self.newline() + else: + reset = True + self.file.write(x) + self.column += len(x) + + def newline(self): + self.file.write("\n") + self.column = 0 + + def writeln(self, s=None): + if s is not None: + self.write(s) + self.newline() + + def indent_to(self, n): + if n0: + self.write(' ') + n -= 1 + +# representation of prolog code that automatically supports proper indentation + +class PrologObject(object): + pass + +class PrologClause(PrologObject): + + def __init__(self, head, body): + self.head = head + self.body = body + + def pp(self, out, offset): + out.indent_to(offset) + out.write(self.head) + out.writeln(" :-") + self.body.pp(out, offset+8) + out.writeln(".") + out.writeln() + +class PrologLiteral(PrologObject): + + def __init__(self, lit): + self.literal = lit + + def pp(self, out, offset): + out.indent_to(offset) + out.write(self.literal) + +class PrologIF(PrologObject): + + def __init__(self, cond, left, right): + self.cond = cond + self.left = left + self.right = right + + def pp(self, out, offset): + out.indent_to(offset) + out.write("("), + indent = offset+1 + self.cond.pp(out, indent) + out.writeln() + out.indent_to(indent) + out.write("-> ") + self.left.pp(out, indent+3) + out.writeln() + out.indent_to(indent) + out.write("; ") + self.right.pp(out, indent+3) + out.write(")") + +ENUM_CLASSES = None +ENUM_CLASSES_AVOID = ('ScriptMode','ViewSelStatus','ExecStatus', + 'ActorProperty','SpaceStatus') + +def enum_classes(): + global ENUM_CLASSES + filename = "gecode-enums-%s.py" % gecode_version() + if SRCDIR is not None: + import os.path + filename = os.path.join(SRCDIR,filename) + if ENUM_CLASSES is None: + import imp + ENUM_CLASSES = imp.load_source( + "gecode_enums", + filename).ENUM_CLASSES + ENUM_CLASSES = (x for x in ENUM_CLASSES if x.TYPE not in ENUM_CLASSES_AVOID) + return ENUM_CLASSES + +class YAPEnumImpl(object): + + def generate(self): + self._generate_atoms() + self._generate_from_term() + + def _generate_atoms(self): + for x in self.ENUM: + print "static YAP_Term gecode_%s;" % x + print + + def _generate_from_term(self): + print "static %s gecode_%s_from_term(YAP_Term X)" % (self.TYPE,self.TYPE) + print "{" + for x in self.ENUM: + print " if (X==gecode_%s) return %s;" % (x,x) + print ' cerr << "this should never happen" << endl; exit(1);' + print "}" + print + + def _generate_from_term_forward_decl(self): + print "static %s gecode_%s_from_term(YAP_Term);" % (self.TYPE,self.TYPE) + +class YAPEnumImplGenerator(object): + + def generate(self): + for c in enum_classes(): + class C(c,YAPEnumImpl): pass + o = C() + o.generate() + +class YAPEnumForwardGenerator(object): + + def generate(self): + for c in enum_classes(): + class C(c,YAPEnumImpl): pass + o = C() + o._generate_from_term_forward_decl() + +class YAPEnumInit(object): + + def generate(self): + for x in self.ENUM: + print '{ YAP_Atom X= YAP_LookupAtom("%s");' % x + print ' gecode_%s = YAP_MkAtomTerm(X);' % x + print ' YAP_AtomGetHold(X); }' + print + +class YAPEnumInitGenerator(object): + + def generate(self): + for c in enum_classes(): + class C(c,YAPEnumInit): pass + o = C() + o.generate() + +class YAPEnumProlog(object): + + def generate(self): + for x in self.ENUM: + print "is_%s_('%s')." % (self.TYPE, x) + print + for x in self.ENUM: + print "is_%s_('%s','%s')." % (self.TYPE, x, x) + print + print "is_%s(X,Y) :- nonvar(X), is_%s_(X,Y)." % (self.TYPE,self.TYPE) + print "is_%s(X) :- is_%s(X,_)." % (self.TYPE,self.TYPE) + print + +class YAPEnumPrologGenerator(object): + + def generate(self): + for c in enum_classes(): + class C(c,YAPEnumProlog): pass + o = C() + o.generate() + +class CCDescriptor(object): + + def __init__(self, name, argtypes, api): + self.name = name + self.argtypes = argtypes + self.api = api + + def generate_impl(self): + print "static int gecode_constraint_%s(void)" % self.api + print "{" + i = 1 + args = [] + for t in self.argtypes: + v = "X%d" % i + a = "YAP_ARG%d" % i + if t=="Space": + v = "*space" + print " GenericSpace* space = gecode_Space_from_term(%s);" % a + else: + extra = "" + if t in ("IntVar","BoolVar","SetVar","IntVarArgs","BoolVarArgs","SetVarArgs"): + extra = "space," + print " %s %s = gecode_%s_from_term(%s%s);" % (t,v,t,extra,a) + args.append(v) + i += 1 + print " %s(%s);" % (self.name, ",".join(args)) + print " return TRUE;" + print "}" + print + + def generate_init(self): + print 'YAP_UserCPredicate("gecode_constraint_%s", gecode_constraint_%s, %d);' \ + % (self.api, self.api, len(self.argtypes)) + +GECODE_VERSION = None + +def gecode_version(): + global GECODE_VERSION + if GECODE_VERSION is not None: + return GECODE_VERSION + from distutils.ccompiler import new_compiler, customize_compiler + import os + cxx = new_compiler() + customize_compiler(cxx) + file_hh = "_gecode_version.hh" + file_txt = "_gecode_version.txt" + f = file(file_hh,"w") + f.write("""#include "gecode/support/config.hpp" +@@GECODE_VERSION""") + f.close() + cxx.preprocess(file_hh,output_file=file_txt) + f = open(file_txt) + version = "" + for line in f: + if line.startswith("@@"): + version = line[3:-2] + break + f.close() + os.remove(file_hh) + os.remove(file_txt) + GECODE_VERSION = version + return version + +SRCDIR = None + +if __name__ == '__main__': + import argparse + parser = argparse.ArgumentParser( + description="code generator for gecode bindings") + parser.add_argument( + "-t", "--target", choices=("yap-prolog","yap-cc-impl","yap-cc-init", + "yap-cc-forward"), + default=None, metavar="TARGET", required=True, + help="type of code to generate") + parser.add_argument( + "-s", "--srcdir", metavar="DIR", default=None, + help="source directory") + + args = parser.parse_args() + if args.srcdir is not None: + import os.path + SRCDIR = os.path.abspath(args.srcdir) + filename = "gecode-prototypes-%s.hh" % gecode_version() + if SRCDIR is not None: + filename = os.path.join(SRCDIR,filename) + if args.target == "yap-prolog": + prolog_print_notice() + YAPEnumPrologGenerator().generate() + YAPConstraintPrologGenerator(filename).generate() + elif args.target == "yap-cc-impl": + cc_print_notice() + YAPEnumImplGenerator().generate() + YAPConstraintCCGenerator(filename).generate_impl() + elif args.target == "yap-cc-init": + cc_print_notice() + YAPEnumInitGenerator().generate() + YAPConstraintCCGenerator(filename).generate_init() + elif args.target == "yap-cc-forward": + cc_print_notice() + YAPEnumForwardGenerator().generate() + else: + raise NotImplementedError("target not yet suported: %s" % args.target) diff --git a/library/gecode/disjunctor.hh b/library/gecode/disjunctor.hh new file mode 100644 index 000000000..6fc2d445d --- /dev/null +++ b/library/gecode/disjunctor.hh @@ -0,0 +1,156 @@ +// -*- c++ -*- +//============================================================================= +// Copyright (C) 2011 by Denys Duchier +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by the +// Free Software Foundation, either version 3 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 Lesser General Public License +// along with this program. If not, see . +//============================================================================= + +#ifndef __GECODE_DISJUNCTOR_HH__ +#define __GECODE_DISJUNCTOR_HH__ + +#include +#include +#include + +namespace Gecode { namespace Disjunctor_ { + + using namespace generic_gecode; + + //========================================================================= + // from a user perspective, a Disjunctor corresponds to a set of + // speculative clauses: + // + // - when a non-committed clause fails, it is simply discarded + // - when a single clause remains, it is committed + // + // from an implementation perspective, a Disjunctor is an object shared by + // several clauses, that contains a counter keeping track of how many + // clauses remain. when the counter reaches 1, the remaining clause + // becomes committed. + //========================================================================= + + // following the example in MPG + struct Disjunctor: public LocalHandle + { + Disjunctor(); + Disjunctor(Space& home); + Disjunctor(const Disjunctor& d); + int get() const; + void incr(); + void decr(); + void dispose(Space& home); + }; + + //========================================================================= + // a Clause encapsulates the speculative execution of a set of propagators. + // Therefore, these propagators must be posted in a separate (sub)space. + // However they normally want to constrain variables of the original home + // space: for each such variable X, a variable Y local to the subspace must + // be created and used instead, and a forwarder must be created from X to + // Y. A Clause is then a Propagator that subscribes to the Xs. Whenever a + // X changes, the domains of the Xs are forwarded into the Ys and + // constraint propagation is run in the subspace. When a clause is + // committed, after propagation, the domains of Ys are forwarded back into + // the Xs. + //========================================================================= + + // TODO: copy (difficulty is forwarder list) + + class SubSpace; + + class Clause: public Propagator { + Disjunctor disj; + SubSpace*const subhome; + public: + Clause(Space& home_, Disjunctor disj_); + Clause(Space& home, bool share, Clause& c); + virtual Propagator* copy(Space& home, bool share); + virtual size_t dispose(Space& home); + virtual PropCost cost(const Space&, const ModEventDelta&) const; + virtual ExecStatus propagate(Space& home, const ModEventDelta&); + // user API + operator GenericSpace&(); + operator Space&(); + operator Home(); + GenericSpace* generic_space() const; + Space* space() const; + void forward(Space& home, IntVar outer, IntVar inner); + void forward(Space& home, BoolVar outer, BoolVar inner); + void forward(Space& home, SetVar outer, SetVar inner); + protected: + ExecStatus forward_in(); + ExecStatus forward_out(Space& outer_home); + bool committed() const; + }; + + //========================================================================= + // a SubSpace is the Space associated with a Clause. It also contains the + // forwarder linked-list because we want it to manage the memory for that + // list. + //========================================================================= + + class BasicForwarder; + using Int::IntView; + using Int::BoolView; + using Set::SetView; + + class SubSpace: public GenericSpace + { + private: + Space* homeDuringCloning; + // linked-list of pairs of a variable in the parent space and a + // corresponding variable in the subspace + BasicForwarder* forwarder; + // auxiliary methods for adding an entry to the forwarder list + void forward(IntView outer, IntView inner); + void forward(BoolView outer, BoolView inner); + void forward(SetView outer, SetView inner); + // for forwarding domains into and out of the subhome + ExecStatus forward_in(); + ExecStatus forward_out(Space&); + // for cancelling subscriptions + void cancel(Space& home, Clause&); + // allow Clause to use this private API + friend class Clause; + public: + SubSpace(); + SubSpace(bool share, SubSpace& s); + virtual Space* copy(bool share); + SubSpace* copy(Space& home, bool share); + }; +}} + +namespace Gecode +{ + using Disjunctor_::Disjunctor; + + class Clause + { + generic_gecode::GenericSpace& _home; + Disjunctor_::Clause* _clause; + public: + Clause(generic_gecode::GenericSpace& home, Disjunctor disj); + operator generic_gecode::GenericSpace&(); + operator Space&(); + operator Home(); + generic_gecode::GenericSpace* generic_space(); + generic_gecode::GenericSpace* generic_parent(); + Space* space(); + void forward(IntVar outer, IntVar inner); + void forward(BoolVar outer, BoolVar inner); + void forward(SetVar outer, SetVar inner); + }; +} + +#endif diff --git a/library/gecode/disjunctor.icc b/library/gecode/disjunctor.icc new file mode 100644 index 000000000..3e1d41285 --- /dev/null +++ b/library/gecode/disjunctor.icc @@ -0,0 +1,380 @@ +// -*- c++ -*- +//============================================================================= +// Copyright (C) 2011 by Denys Duchier +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by the +// Free Software Foundation, either version 3 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 Lesser General Public License +// along with this program. If not, see . +//============================================================================= +#include "disjunctor.hh" + +namespace Gecode { namespace Disjunctor_ { + + //========================================================================= + // Disjunctor (following example in MPG) + //========================================================================= + + struct DisjunctorObject: public LocalObject + { + int n; + DisjunctorObject(Space& home) : LocalObject(home), n(0) {} + DisjunctorObject(Space& home, bool share, DisjunctorObject& d) + : LocalObject(home, share, d), n(d.n) {} + virtual LocalObject* copy(Space& home, bool share) + { return new (home) DisjunctorObject(home, share, *this); } + virtual size_t dispose(Space&) { return sizeof(*this); } + }; + + Disjunctor::Disjunctor(): LocalHandle() {} + Disjunctor::Disjunctor(Space& home) + : LocalHandle(new (home) DisjunctorObject(home)) {} + Disjunctor::Disjunctor(const Disjunctor& d): LocalHandle(d) {} + int Disjunctor::get() const { return static_cast(object())->n; } + void Disjunctor::incr() { static_cast(object())->n += 1; } + void Disjunctor::decr() { static_cast(object())->n -= 1; } + void Disjunctor::dispose(Space& home) + { static_cast(object())->dispose(home); } + + //========================================================================= + // Forwarder + // used to forward the domain of a view V1 into a view V2 located in a + // subspace (the subspace of a speculative clause). V2 represents V1 in + // that space. + // + // BasicForwarder + // base class of all Forwarders. It declares the virtual functions + // that must be implemented to do the actual work, and contains the pointer + // implementing the singly-linked list of Forwarders associated with each + // clause. It also redefines new and delete to manage memory in the + // subspace. + //========================================================================= + + struct BasicForwarder + { + BasicForwarder* next; + + BasicForwarder() : next(NULL) {} + + // forward V1's domain into V2. This is used each time the Clause (as a + // a propagator) is woken to perform propagation. + + virtual ExecStatus forward_in(Space& inner_home) = 0; + + // forward V2's domain into V1. This is used after propagation in the + // case where the Clause has been committed to (because it is the last + // one remaining). + + virtual void forward_out(Space& outer_home) = 0; + + // needed by delete to know how much to free + virtual size_t size() const = 0; + + // usage: new (home) FRWRDR(...); + // to allocate the instance of FRWRDR on home's heap + + static void* operator new(size_t n, Space& home) + { return home.ralloc(n); } + + // usage: delete (home) PTR; + // to free the instance pointed to by PTR from home's heap + + static void operator delete(void* ptr, Space& home) + { home.rfree(ptr, ((BasicForwarder*)ptr)->size()); } + + virtual BasicForwarder* + copy(Space& outer_home, Space& inner_home, bool share) = 0; + + virtual void cancel(Space& home, Clause&) = 0; + }; + + // Forwarder parametrized by View + + template + struct Forwarder: public BasicForwarder + { + View outer; + View inner; + Forwarder(View v1, View v2): outer(v1), inner(v2) {} + Forwarder() {} + virtual ExecStatus forward_in(Space& home); + virtual void forward_out(Space& home); + virtual size_t size() const { return sizeof(*this); } + virtual BasicForwarder* copy(Space& outer_home, Space& inner_home, bool share) + { + Forwarder* fwd = new (inner_home) Forwarder(); + fwd->outer.update(outer_home, share, outer); + fwd->inner.update(inner_home, share, inner); + return fwd; + } + virtual void cancel(Space& home, Clause& c); + }; + + // instances of Forwarder that we actually use + + typedef Forwarder IntForwarder; + typedef Forwarder BoolForwarder; + typedef Forwarder SetForwarder; + + //========================================================================= + // IntForwarder + //========================================================================= + + template <> + ExecStatus IntForwarder::forward_in(Space& home) // inner home + { + Int::ViewRanges r(outer); + GECODE_ME_CHECK(inner.inter_r(home,r)); + return ES_OK; + } + + template <> + void IntForwarder::forward_out(Space& home) // outer home + { + // it is guaranteed by design that after successful propagation the + // domain of the inner variable is a non-empty narrowing of the domain of + // the outer variable. therefore, we can simply replace the domain of + // the outer variable with the domain of the inner variable. + Int::ViewRanges r(inner); + outer.narrow_r(home, r, false); + } + + template <> + void IntForwarder::cancel(Space& home, Clause& c) + { outer.cancel(home, c, Int::PC_INT_DOM); } + + //========================================================================= + // BoolForwarder + //========================================================================= + + template <> + ExecStatus BoolForwarder::forward_in(Space& home) + { + Int::ViewRanges r(outer); + GECODE_ME_CHECK(inner.inter_r(home,r)); + return ES_OK; + } + + template <> + void BoolForwarder::forward_out(Space& home) + { + Int::ViewRanges r(inner); + outer.narrow_r(home, r, false); + } + + template <> + void BoolForwarder::cancel(Space& home, Clause& c) + { outer.cancel(home, c, Int::PC_INT_DOM); } + + //========================================================================= + // SetForwarder + //========================================================================= + + template <> + ExecStatus SetForwarder::forward_in(Space& home) + { + Set::GlbRanges gr(outer); + GECODE_ME_CHECK(inner.includeI(home,gr)); + Set::LubRanges lr(outer); + GECODE_ME_CHECK(inner.intersectI(home,lr)); + GECODE_ME_CHECK(inner.cardMin(home, outer.cardMin())); + GECODE_ME_CHECK(inner.cardMax(home, outer.cardMax())); + return ES_OK; + } + + template <> + void SetForwarder::forward_out(Space& home) + { + Set::GlbRanges gr(inner); + outer.includeI(home, gr); + Set::LubRanges lr(inner); + outer.intersectI(home, lr); + outer.cardMin(home, inner.cardMin()); + outer.cardMax(home, inner.cardMax()); + } + + template <> + void SetForwarder::cancel(Space& home, Clause& c) + { outer.cancel(home, c, Set::PC_SET_ANY); } + + //========================================================================= + // SubSpace + //========================================================================= + + void SubSpace::forward(IntView outer, IntView inner) + { + BasicForwarder* fwd = new (*this) IntForwarder(outer, inner); + fwd->next = forwarder; + forwarder = fwd; + } + + void SubSpace::forward(BoolView outer, BoolView inner) + { + BasicForwarder* fwd = new (*this) BoolForwarder(outer, inner); + fwd->next = forwarder; + forwarder = fwd; + } + + void SubSpace::forward(SetView outer, SetView inner) + { + BasicForwarder* fwd = new (*this) SetForwarder(outer, inner); + fwd->next = forwarder; + forwarder = fwd; + } + + ExecStatus SubSpace::forward_in() + { + for (BasicForwarder* p=forwarder; p!=NULL; p=p->next) + GECODE_ES_CHECK(p->forward_in(*this)); + return ES_OK; + } + + ExecStatus SubSpace::forward_out(Space& home) // outer home + { + for (BasicForwarder* p=forwarder; p!=NULL; p=p->next) + p->forward_out(home); + return ES_OK; + } + + SubSpace::SubSpace(): GenericSpace(), forwarder(NULL) {} + + SubSpace::SubSpace(bool share, SubSpace& s) + : GenericSpace(share, s), forwarder(NULL) + { + BasicForwarder** prev = &forwarder; + for (BasicForwarder* p=s.forwarder; p!=NULL; p=p->next) + { + BasicForwarder* fwd = p->copy(*s.homeDuringCloning, *this, share); + *prev = fwd; + prev = &fwd->next; + } + } + + Space* SubSpace::copy(bool share) + { return new SubSpace(share,*this); } + + SubSpace* SubSpace::copy(Space& home, bool share) + { homeDuringCloning = &home; return static_cast(clone(share)); } + + void SubSpace::cancel(Space& home, Clause& c) + { + for (BasicForwarder*p = forwarder; p!=NULL; p=p->next) + p->cancel(home, c); + } + + //========================================================================= + // Clause + //========================================================================= + + Clause::operator GenericSpace&() { return *subhome; } + Clause::operator Space&() { return *subhome; } + Clause::operator Home() { return *subhome; } + + GenericSpace* Clause::generic_space() const { return subhome; } + Space* Clause::space() const { return subhome; } + + Clause::Clause(Space& home_, Disjunctor disj_) + : Propagator(home_), disj(disj_), subhome(new SubSpace()) + { + disj.incr(); + } + + Clause::Clause(Space& home, bool share, Clause& c) + : Propagator(home, share, c), subhome(c.subhome->copy(home, share)) + { + disj.update(home, share, c.disj); + } + + Propagator* Clause::copy(Space& home, bool share) + { return new (home) Clause(home, share, *this); } + + void Clause::forward(Space& home, IntVar outer, IntVar inner) + { + IntView oview(outer); + IntView iview(inner); + subhome->forward(oview, iview); + oview.subscribe(home, *this, Int::PC_INT_DOM); + } + + void Clause::forward(Space& home, BoolVar outer, BoolVar inner) + { + BoolView oview(outer); + BoolView iview(inner); + subhome->forward(oview, iview); + oview.subscribe(home, *this, Int::PC_INT_DOM); + } + + void Clause::forward(Space& home, SetVar outer, SetVar inner) + { + SetView oview(outer); + SetView iview(inner); + subhome->forward(oview, iview); + oview.subscribe(home, *this, Set::PC_SET_ANY); + } + + ExecStatus Clause::forward_in() + { return subhome->forward_in(); } + + ExecStatus Clause::forward_out(Space& home) // outer home + { return subhome->forward_out(home); } + + inline bool Clause::committed() const { return disj.get() == 1; } + + ExecStatus Clause::propagate(Space& home, const ModEventDelta&) + { + if (forward_in() == ES_FAILED || + subhome->status() == SS_FAILED ) + { + if (committed()) return ES_FAILED; + disj.decr(); + return home.ES_SUBSUMED(*this); + } + if (committed()) forward_out(home); + // maybe do something clever about subsumption later + return ES_FIX; + } + + size_t Clause::dispose(Space& home) + { + subhome->cancel(home, *this); + delete subhome; + // the memory for the disj's LocalObject is not recovered + (void) Propagator::dispose(home); + return sizeof(*this); + } + + PropCost Clause::cost(const Space&, const ModEventDelta&) const + { + // consider a clause to be crazy expensive + return PropCost::crazy(PropCost::HI,10); + } +} + + //=========================================================================== + // Clause (user API) + //=========================================================================== + + Clause::Clause(generic_gecode::GenericSpace& home, Disjunctor disj) + : _home(home), _clause(new (home) Disjunctor_::Clause(home, disj)) {} + Clause::operator generic_gecode::GenericSpace&() { return *_clause; } + Clause::operator Space&() { return *_clause; } + Clause::operator Home() { return *_clause; } + generic_gecode::GenericSpace* Clause::generic_space() { return _clause->generic_space(); } + generic_gecode::GenericSpace* Clause::generic_parent() { return &_home; } + Space* Clause::space() { return _clause->space(); } + void Clause::forward(IntVar outer, IntVar inner) + { _clause->forward(_home, outer, inner); } + void Clause::forward(BoolVar outer, BoolVar inner) + { _clause->forward(_home, outer, inner); } + void Clause::forward(SetVar outer, SetVar inner) + { _clause->forward(_home, outer, inner); } + +} diff --git a/library/gecode/disjunctor1.yap b/library/gecode/disjunctor1.yap new file mode 100644 index 000000000..170a5fd84 --- /dev/null +++ b/library/gecode/disjunctor1.yap @@ -0,0 +1,37 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +:- use_module(gecode). + +disjunctor1(X_,Y_) :- + Space := space, + [X,Y] := intvars(Space,2,0,3), + D := disjunctor(Space), + C1 := clause(D), + [X1,Y1] := intvars(C1,2,0,3), + C1 += rel(X1,'IRT_EQ',1), + C1 += rel(Y1,'IRT_EQ',1), + C1 += forward([X,Y],[X1,Y1]), + C2 := clause(D), + [X2,Y2] := intvars(C2,2,0,3), + C2 += rel(X2,'IRT_EQ',2), + C2 += rel(Y2,'IRT_EQ',2), + C2 += forward([X,Y],[X2,Y2]), + Space += branch([X,Y],'INT_VAR_SIZE_MIN','INT_VAL_MIN'), + SolSpace := search(Space), + [X_,Y_] := val(SolSpace,[X,Y]). diff --git a/library/gecode/disjunctor2.yap b/library/gecode/disjunctor2.yap new file mode 100644 index 000000000..cf4fcd6a6 --- /dev/null +++ b/library/gecode/disjunctor2.yap @@ -0,0 +1,37 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +:- use_module(gecode). + +disjunctor2(X_,Y_) :- + Space := space, + [X,Y] := intvars(Space,2,0,3), + D := disjunctor(Space), + C1 := clause(D), + [X1,Y1] := intvars(C1,2,0,3), + C1 += forward([X,Y],[X1,Y1]), + C1 += rel(X1,'IRT_EQ',0), + C1 += rel(Y1,'IRT_EQ',0), + C2 := clause(D), + [X2,Y2] := intvars(C2,2,0,3), + C2 += forward([X,Y],[X2,Y2]), + Z2 := intvar(C2,1,2), + C2 += linear([-1,1,1],[X2,Y2,Z2],'IRT_EQ',0), + Space += branch([X,Y],'INT_VAR_SIZE_MIN','INT_VAL_MIN'), + SolSpace := search(Space), + [X_,Y_] := val(SolSpace,[X,Y]). diff --git a/library/gecode/extractor/Doxyfile.in b/library/gecode/extractor/Doxyfile.in new file mode 100644 index 000000000..e20ff3563 --- /dev/null +++ b/library/gecode/extractor/Doxyfile.in @@ -0,0 +1,1716 @@ +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = Gecode + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = @GECODEDIR@ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = ISO-8859-1 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.hh *.hpp + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = NO + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = YES + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/library/gecode/extractor/Makefile b/library/gecode/extractor/Makefile new file mode 100644 index 000000000..3fc261ab7 --- /dev/null +++ b/library/gecode/extractor/Makefile @@ -0,0 +1,33 @@ +GECODEDIR := $(shell g++ -q $(CPPFLAGS) $(CXXFLAGS) -H -E gecodedir.hh 2>&1 >/dev/null | grep gecode/kernel.hh | awk '{print $$2}' | sed 's|/kernel.hh||') +GECODECONFIG := $(GECODEDIR)/support/config.hpp +GECODEVERSION := $(shell cat $(GECODECONFIG) | egrep GECODE_VERSION | awk '{print $$3}' | sed 's/"//g') +PROTOTYPES = gecode-prototypes-$(GECODEVERSION).hh +ENUMS = gecode-enums-$(GECODEVERSION).py + +all: $(PROTOTYPES) $(ENUMS) + +$(PROTOTYPES): % : xml/namespaceGecode.xml extract-prototypes.xsl + cat notice.hh > $@ + xsltproc extract-prototypes.xsl $< \ + | sed 's/Gecode:://g' \ + | sed 's/< //>/g' \ + | sed 's/ \&/\&/g' \ + | sed 's/, /,/g' \ + | sed 's/forceinline //g' \ + | sed 's/GECODE_INT_EXPORT //g' \ + | sed 's/GECODE_SET_EXPORT //g' \ + | grep -v '*' | sort >> $@ + +$(ENUMS): % : xml/namespaceGecode.xml extract-enums.xsl + cat notice.py > $@ + xsltproc extract-enums.xsl $< >> $@ + +xml/namespaceGecode.xml: Doxyfile + doxygen Doxyfile + +Doxyfile: Doxyfile.in + cat $< | sed "s#@GECODEDIR@#$(GECODEDIR)#" > $@ + +clean: + -rm -rf *~ gecode-prototypes-*.hh gecode-enums-*.py Doxyfile xml diff --git a/library/gecode/extractor/README b/library/gecode/extractor/README new file mode 100644 index 000000000..6a098164e --- /dev/null +++ b/library/gecode/extractor/README @@ -0,0 +1,2 @@ +This directory contains support code for automatically extracting +prototypes from the local Gecode installation. diff --git a/library/gecode/extractor/extract-enums.xsl b/library/gecode/extractor/extract-enums.xsl new file mode 100644 index 000000000..313e8d6f7 --- /dev/null +++ b/library/gecode/extractor/extract-enums.xsl @@ -0,0 +1,31 @@ + + + + ENUM_CLASSES = [] + + + + class + + (object): + + TYPE = ' + + ' + ENUM = [ + + , + ' + + ' + + ] + +ENUM_CLASSES.append( + + ) + + + + + diff --git a/library/gecode/extractor/extract-prototypes.xsl b/library/gecode/extractor/extract-prototypes.xsl new file mode 100644 index 000000000..7ceacbaf7 --- /dev/null +++ b/library/gecode/extractor/extract-prototypes.xsl @@ -0,0 +1,21 @@ + + + + + + + + + ( + , + + + = + + + + ); + + + + diff --git a/library/gecode/extractor/gecodedir.hh b/library/gecode/extractor/gecodedir.hh new file mode 100644 index 000000000..b3cc63621 --- /dev/null +++ b/library/gecode/extractor/gecodedir.hh @@ -0,0 +1 @@ +#include "gecode/kernel.hh" diff --git a/library/gecode/extractor/notice.hh b/library/gecode/extractor/notice.hh new file mode 100644 index 000000000..935fe8212 --- /dev/null +++ b/library/gecode/extractor/notice.hh @@ -0,0 +1,3 @@ +// This file was automatically extracted from Gecode source files. +// It is subject to the same Copyright as the source files from which +// it is derived, and is distributed under the same Licensing conditions. diff --git a/library/gecode/extractor/notice.py b/library/gecode/extractor/notice.py new file mode 100644 index 000000000..cdfd4d2cd --- /dev/null +++ b/library/gecode/extractor/notice.py @@ -0,0 +1,3 @@ +# This file was automatically extracted from Gecode source files. +# It is subject to the same Copyright as the source files from which +# it is derived, and is distributed under the same Licensing conditions. diff --git a/library/gecode/gecode-common.icc b/library/gecode/gecode-common.icc new file mode 100644 index 000000000..029227e17 --- /dev/null +++ b/library/gecode/gecode-common.icc @@ -0,0 +1,259 @@ +// -*- c++ -*- +//============================================================================= +// Copyright (C) 2011 by Denys Duchier +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by the +// Free Software Foundation, either version 3 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 Lesser General Public License +// along with this program. If not, see . +//============================================================================= + +#ifndef GECODE_COMMON +#define GECODE_COMMON + +#include "gecode/int.hh" +#include "gecode/set.hh" +#include "gecode/search.hh" +#include + +namespace generic_gecode +{ + using namespace std; + using namespace Gecode; + + // description of the optimization criterion + struct Optimizing + { + enum What { OPT_NONE, OPT_INT, OPT_RATIO }; + enum How { OPT_MIN, OPT_MAX }; + int num; + int den; + What what; + How how; + Optimizing(): num(-1), den(-1), what(OPT_NONE), how(OPT_MAX) {} + Optimizing(Optimizing& o) + : num(o.num), den(o.den), what(o.what), how(o.how) {} + void maximize(int i) + { what = OPT_INT; how = OPT_MAX; num = i; }; + void maximize(int i,int j) + { what = OPT_RATIO; how = OPT_MAX; num = i; den = j; }; + void minimize(int i) + { what = OPT_INT; how = OPT_MIN; num = i; }; + void minimize(int i,int j) + { what = OPT_RATIO; how = OPT_MIN; num = i; den = j; }; + }; + + struct GenericSpace; + + struct GenericEngine + { + virtual GenericSpace* next(void)=0; + virtual ~GenericEngine() {}; + }; + + struct GenericDFS: GenericEngine + { + DFS engine; + GenericDFS(GenericSpace* s) : engine(s) {} + virtual GenericSpace* next(void) { return engine.next(); } + }; + + struct GenericBAB: GenericEngine + { + BAB engine; + GenericBAB(GenericSpace* s) : engine(s) {} + virtual GenericSpace* next(void) { return engine.next(); } + }; + + struct GenericSpace: Space + { + Optimizing optim; + IntVarArray ivars; + BoolVarArray bvars; + SetVarArray svars; + vector* _ivars; + vector* _bvars; + vector* _svars; + + Space* space() { return this; } + + GenericSpace(bool share, GenericSpace& s) + : Space(share, s), optim(s.optim), + _ivars(NULL), _bvars(NULL), _svars(NULL) + { + ivars.update(*this, share, s.ivars); + bvars.update(*this, share, s.bvars); + svars.update(*this, share, s.svars); + } + + Space* copy(bool share) + { freeze(); return new GenericSpace(share, *this); } + + GenericSpace() : _ivars(NULL), _bvars(NULL), _svars(NULL) {} + + // freeze the space before handing it off to a search engine + void freeze() + { + if (_ivars) + { + int n = _ivars->size(); + ivars = IntVarArray(*this, n); + vector& v(*_ivars); + for (; n--;) ivars[n] = v[n]; + delete _ivars; + _ivars = NULL; + } + + if (_bvars) + { + int n = _bvars->size(); + bvars = BoolVarArray(*this, n); + vector& v(*_bvars); + for (; n--;) bvars[n] = v[n]; + delete _bvars; + _bvars = NULL; + } + + if (_svars) + { + int n = _svars->size(); + svars = SetVarArray(*this, n); + vector& v(*_svars); + for (; n--;) svars[n] = v[n]; + delete _svars; + _svars = NULL; + } + } + + IntVar get_ivar(int i) const { return (_ivars) ? (*_ivars)[i] : ivars[i]; } + BoolVar get_bvar(int i) const { return (_bvars) ? (*_bvars)[i] : bvars[i]; } + SetVar get_svar(int i) const { return (_svars) ? (*_svars)[i] : svars[i]; } + + GenericEngine* new_engine() + { + freeze(); + return (optim.what == Optimizing::OPT_NONE) + ? static_cast(new GenericDFS(this)) + : static_cast(new GenericBAB(this)); + } + + int _new_ivar(IntVar& v) + { + if (!_ivars) _ivars = new vector; + int i = _ivars->size(); + _ivars->push_back(v); + return i; + } + + int new_ivar(int lo, int hi) + { + IntVar v(*this, lo, hi); + return _new_ivar(v); + } + + int new_ivar(IntSet& s) + { + IntVar v(*this, s); + return _new_ivar(v); + } + + int _new_bvar(BoolVar& v) + { + if (!_bvars) _bvars = new vector; + int i = _bvars->size(); + _bvars->push_back(v); + return i; + } + + int new_bvar() + { + BoolVar v(*this, 0, 1); + return _new_bvar(v); + } + + int _new_svar(SetVar& v) + { + if (!_svars) _svars = new vector; + int i = _svars->size(); + _svars->push_back(v); + return i; + } + + int new_svar(int glbMin, int glbMax, int lubMin, int lubMax, + unsigned int cardMin=0, + unsigned int cardMax=Set::Limits::card) + { + SetVar v(*this, glbMin, glbMax, lubMin, lubMax, cardMin, cardMax); + return _new_svar(v); + } + + int new_svar(IntSet glb, int lubMin, int lubMax, + unsigned int cardMin=0, + unsigned int cardMax=Set::Limits::card) + { + SetVar v(*this, glb, lubMin, lubMax, cardMin, cardMax); + return _new_svar(v); + } + + int new_svar(int glbMin, int glbMax, IntSet lub, + unsigned int cardMin=0, + unsigned int cardMax=Set::Limits::card) + { + SetVar v(*this, glbMin, glbMax, lub, cardMin, cardMax); + return _new_svar(v); + } + + int new_svar(IntSet glb, IntSet lub, + unsigned int cardMin=0, + unsigned int cardMax=Set::Limits::card) + { + SetVar v(*this, glb, lub, cardMin, cardMax); + return _new_svar(v); + } + + void minimize(int i) { optim.minimize(i); } + void minimize(int i, int j) { optim.minimize(i,j); } + void maximize(int i) { optim.maximize(i); } + void maximize(int i, int j) { optim.maximize(i,j); } + + virtual void constrain(const Space& s) + { + const GenericSpace& sol = static_cast(s); + switch (optim.what) + { + case Optimizing::OPT_NONE: + break; + case Optimizing::OPT_INT: + rel(*this, ivars[optim.num], + ((optim.how==Optimizing::OPT_MIN) ? IRT_LE : IRT_GR), + sol.ivars[optim.num].val()); + break; + case Optimizing::OPT_RATIO: + { + IntArgs c(2, sol.ivars[optim.den].val(), + - sol.ivars[optim.num].val()); + IntVarArgs v(2); + v[0] = ivars[optim.num]; + v[1] = ivars[optim.den]; + linear(*this, c, v, + ((optim.how==Optimizing::OPT_MIN) ? IRT_LE : IRT_GR), 0); + break; + } + } + } + }; +} + +#ifdef DISJUNCTOR +#include "disjunctor.icc" +#endif + +#endif diff --git a/library/gecode/gecode-enums-3.6.0.py b/library/gecode/gecode-enums-3.6.0.py new file mode 100644 index 000000000..838a0deb2 --- /dev/null +++ b/library/gecode/gecode-enums-3.6.0.py @@ -0,0 +1,113 @@ +# This file was automatically extracted from Gecode source files. +# It is subject to the same Copyright as the source files from which +# it is derived, and is distributed under the same Licensing conditions. +ENUM_CLASSES = [] + +class ScriptMode(object): + TYPE = 'ScriptMode' + ENUM = ['SM_SOLUTION','SM_TIME','SM_STAT','SM_GIST'] + +ENUM_CLASSES.append(ScriptMode) + +class IntRelType(object): + TYPE = 'IntRelType' + ENUM = ['IRT_EQ','IRT_NQ','IRT_LQ','IRT_LE','IRT_GQ','IRT_GR'] + +ENUM_CLASSES.append(IntRelType) + +class BoolOpType(object): + TYPE = 'BoolOpType' + ENUM = ['BOT_AND','BOT_OR','BOT_IMP','BOT_EQV','BOT_XOR'] + +ENUM_CLASSES.append(BoolOpType) + +class IntConLevel(object): + TYPE = 'IntConLevel' + ENUM = ['ICL_VAL','ICL_BND','ICL_DOM','ICL_DEF'] + +ENUM_CLASSES.append(IntConLevel) + +class TaskType(object): + TYPE = 'TaskType' + ENUM = ['TT_FIXP','TT_FIXS','TT_FIXE'] + +ENUM_CLASSES.append(TaskType) + +class ExtensionalPropKind(object): + TYPE = 'ExtensionalPropKind' + ENUM = ['EPK_DEF','EPK_SPEED','EPK_MEMORY'] + +ENUM_CLASSES.append(ExtensionalPropKind) + +class IntVarBranch(object): + TYPE = 'IntVarBranch' + ENUM = ['INT_VAR_NONE','INT_VAR_RND','INT_VAR_DEGREE_MIN','INT_VAR_DEGREE_MAX','INT_VAR_AFC_MIN','INT_VAR_AFC_MAX','INT_VAR_MIN_MIN','INT_VAR_MIN_MAX','INT_VAR_MAX_MIN','INT_VAR_MAX_MAX','INT_VAR_SIZE_MIN','INT_VAR_SIZE_MAX','INT_VAR_SIZE_DEGREE_MIN','INT_VAR_SIZE_DEGREE_MAX','INT_VAR_SIZE_AFC_MIN','INT_VAR_SIZE_AFC_MAX','INT_VAR_REGRET_MIN_MIN','INT_VAR_REGRET_MIN_MAX','INT_VAR_REGRET_MAX_MIN','INT_VAR_REGRET_MAX_MAX'] + +ENUM_CLASSES.append(IntVarBranch) + +class IntValBranch(object): + TYPE = 'IntValBranch' + ENUM = ['INT_VAL_MIN','INT_VAL_MED','INT_VAL_MAX','INT_VAL_RND','INT_VAL_SPLIT_MIN','INT_VAL_SPLIT_MAX','INT_VAL_RANGE_MIN','INT_VAL_RANGE_MAX','INT_VALUES_MIN','INT_VALUES_MAX'] + +ENUM_CLASSES.append(IntValBranch) + +class IntAssign(object): + TYPE = 'IntAssign' + ENUM = ['INT_ASSIGN_MIN','INT_ASSIGN_MED','INT_ASSIGN_MAX','INT_ASSIGN_RND'] + +ENUM_CLASSES.append(IntAssign) + +class ViewSelStatus(object): + TYPE = 'ViewSelStatus' + ENUM = ['VSS_BEST','VSS_BETTER','VSS_TIE','VSS_WORSE'] + +ENUM_CLASSES.append(ViewSelStatus) + +class ExecStatus(object): + TYPE = 'ExecStatus' + ENUM = ['__ES_SUBSUMED','ES_FAILED','ES_NOFIX','ES_OK','ES_FIX','ES_NOFIX_FORCE','__ES_PARTIAL'] + +ENUM_CLASSES.append(ExecStatus) + +class ActorProperty(object): + TYPE = 'ActorProperty' + ENUM = ['AP_DISPOSE','AP_WEAKLY'] + +ENUM_CLASSES.append(ActorProperty) + +class SpaceStatus(object): + TYPE = 'SpaceStatus' + ENUM = ['SS_FAILED','SS_SOLVED','SS_BRANCH'] + +ENUM_CLASSES.append(SpaceStatus) + +class SetRelType(object): + TYPE = 'SetRelType' + ENUM = ['SRT_EQ','SRT_NQ','SRT_SUB','SRT_SUP','SRT_DISJ','SRT_CMPL'] + +ENUM_CLASSES.append(SetRelType) + +class SetOpType(object): + TYPE = 'SetOpType' + ENUM = ['SOT_UNION','SOT_DUNION','SOT_INTER','SOT_MINUS'] + +ENUM_CLASSES.append(SetOpType) + +class SetVarBranch(object): + TYPE = 'SetVarBranch' + ENUM = ['SET_VAR_NONE','SET_VAR_RND','SET_VAR_DEGREE_MIN','SET_VAR_DEGREE_MAX','SET_VAR_AFC_MIN','SET_VAR_AFC_MAX','SET_VAR_MIN_MIN','SET_VAR_MIN_MAX','SET_VAR_MAX_MIN','SET_VAR_MAX_MAX','SET_VAR_SIZE_MIN','SET_VAR_SIZE_MAX','SET_VAR_SIZE_DEGREE_MIN','SET_VAR_SIZE_DEGREE_MAX','SET_VAR_SIZE_AFC_MIN','SET_VAR_SIZE_AFC_MAX'] + +ENUM_CLASSES.append(SetVarBranch) + +class SetValBranch(object): + TYPE = 'SetValBranch' + ENUM = ['SET_VAL_MIN_INC','SET_VAL_MIN_EXC','SET_VAL_MED_INC','SET_VAL_MED_EXC','SET_VAL_MAX_INC','SET_VAL_MAX_EXC','SET_VAL_RND_INC','SET_VAL_RND_EXC'] + +ENUM_CLASSES.append(SetValBranch) + +class SetAssign(object): + TYPE = 'SetAssign' + ENUM = ['SET_ASSIGN_MIN_INC','SET_ASSIGN_MIN_EXC','SET_ASSIGN_MED_INC','SET_ASSIGN_MED_EXC','SET_ASSIGN_MAX_INC','SET_ASSIGN_MAX_EXC','SET_ASSIGN_RND_INC','SET_ASSIGN_RND_EXC'] + +ENUM_CLASSES.append(SetAssign) + diff --git a/library/gecode/gecode-enums-3.6.0.pyc b/library/gecode/gecode-enums-3.6.0.pyc new file mode 100644 index 000000000..959eb1290 Binary files /dev/null and b/library/gecode/gecode-enums-3.6.0.pyc differ diff --git a/library/gecode/gecode-prototypes-3.6.0.hh b/library/gecode/gecode-prototypes-3.6.0.hh new file mode 100644 index 000000000..8e5189e4a --- /dev/null +++ b/library/gecode/gecode-prototypes-3.6.0.hh @@ -0,0 +1,209 @@ +// This file was automatically extracted from Gecode source files. +// It is subject to the same Copyright as the source files from which +// it is derived, and is distributed under the same Licensing conditions. +void abs(Home,IntVar,IntVar,IntConLevel=ICL_DEF); +void assign(Home,BoolVar,IntAssign,const ValBranchOptions&=ValBranchOptions::def); +void assign(Home,const BoolVarArgs&,IntAssign,const ValBranchOptions&=ValBranchOptions::def); +void assign(Home,const IntVarArgs&,IntAssign,const ValBranchOptions&=ValBranchOptions::def); +void assign(Home,const SetVarArgs&,SetAssign,const ValBranchOptions&=ValBranchOptions::def); +void assign(Home,IntVar,IntAssign,const ValBranchOptions&=ValBranchOptions::def); +void assign(Home,SetVar,SetAssign,const ValBranchOptions&=ValBranchOptions::def); +void atmostOne(Home,const SetVarArgs&,unsigned int); +void binpacking(Home,const IntVarArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void branch(Home,BoolVar,IntValBranch,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const BoolVarArgs&,const TieBreakVarBranch&,IntValBranch,const TieBreakVarBranchOptions&=TieBreakVarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const BoolVarArgs&,IntVarBranch,IntValBranch,const VarBranchOptions&=VarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const IntVarArgs&,const TieBreakVarBranch&,IntValBranch,const TieBreakVarBranchOptions&=TieBreakVarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const IntVarArgs&,IntVarBranch,IntValBranch,const VarBranchOptions&=VarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const SetVarArgs&,const TieBreakVarBranch&,SetValBranch,const TieBreakVarBranchOptions&=TieBreakVarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,const SetVarArgs&,SetVarBranch,SetValBranch,const VarBranchOptions&=VarBranchOptions::def,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,IntVar,IntValBranch,const ValBranchOptions&=ValBranchOptions::def); +void branch(Home,SetVar,SetValBranch,const ValBranchOptions&=ValBranchOptions::def); +void cardinality(Home,SetVar,IntVar); +void cardinality(Home,SetVar,unsigned int,unsigned int); +void channel(Home,BoolVar,IntVar,IntConLevel=ICL_DEF); +void channel(Home,const BoolVarArgs&,IntVar,int=0,IntConLevel=ICL_DEF); +void channel(Home,const BoolVarArgs&,SetVar); +void channel(Home,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void channel(Home,const IntVarArgs&,const SetVarArgs&); +void channel(Home,const IntVarArgs&,int,const IntVarArgs&,int,IntConLevel=ICL_DEF); +void channel(Home,IntVar,BoolVar,IntConLevel=ICL_DEF); +void channelSorted(Home,const IntVarArgs&,SetVar); +void circuit(Home,const IntArgs&,const IntVarArgs&,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void circuit(Home,const IntArgs&,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void circuit(Home,const IntArgs&,int,const IntVarArgs&,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void circuit(Home,const IntArgs&,int,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void circuit(Home,const IntVarArgs&,IntConLevel=ICL_DEF); +void circuit(Home,int,const IntVarArgs&,IntConLevel=ICL_DEF); +void clause(Home,BoolOpType,const BoolVarArgs&,const BoolVarArgs&,BoolVar,IntConLevel=ICL_DEF); +void clause(Home,BoolOpType,const BoolVarArgs&,const BoolVarArgs&,int,IntConLevel=ICL_DEF); +void convex(Home,SetVar); +void convex(Home,SetVar,SetVar); +void count(Home,const IntVarArgs&,const IntArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntSetArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntSetArgs&,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntSet&,const IntArgs&,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,int,IntRelType,int,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,int,IntRelType,IntVar,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,IntVar,IntRelType,int,IntConLevel=ICL_DEF); +void count(Home,const IntVarArgs&,IntVar,IntRelType,IntVar,IntConLevel=ICL_DEF); +void cumulative(Home,int,const IntVarArgs&,const IntArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,int,const IntVarArgs&,const IntArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,int,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,int,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,int,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,int,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const IntVarArgs&,const IntArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const IntVarArgs&,const IntArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void cumulative(Home,IntVar,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntArgs&,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntArgs&,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void cumulatives(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntArgs&,bool,IntConLevel=ICL_DEF); +void distinct(Home,const IntArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void distinct(Home,const IntVarArgs&,IntConLevel=ICL_DEF); +void div(Home,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void divmod(Home,IntVar,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void dom(Home,const IntVarArgs&,const IntSet&,IntConLevel=ICL_DEF); +void dom(Home,const IntVarArgs&,int,IntConLevel=ICL_DEF); +void dom(Home,const IntVarArgs&,int,int,IntConLevel=ICL_DEF); +void dom(Home,IntVar,const IntSet&,BoolVar,IntConLevel=ICL_DEF); +void dom(Home,IntVar,const IntSet&,IntConLevel=ICL_DEF); +void dom(Home,IntVar,int,BoolVar,IntConLevel=ICL_DEF); +void dom(Home,IntVar,int,int,BoolVar,IntConLevel=ICL_DEF); +void dom(Home,IntVar,int,IntConLevel=ICL_DEF); +void dom(Home,IntVar,int,int,IntConLevel=ICL_DEF); +void dom(Home,SetVar,SetRelType,const IntSet&); +void dom(Home,SetVar,SetRelType,const IntSet&,BoolVar); +void dom(Home,SetVar,SetRelType,int); +void dom(Home,SetVar,SetRelType,int,BoolVar); +void dom(Home,SetVar,SetRelType,int,int); +void dom(Home,SetVar,SetRelType,int,int,BoolVar); +void element(Home,const BoolVarArgs&,IntVar,BoolVar,IntConLevel=ICL_DEF); +void element(Home,const BoolVarArgs&,IntVar,int,IntConLevel=ICL_DEF); +void element(Home,const BoolVarArgs&,IntVar,int,IntVar,int,BoolVar,IntConLevel=ICL_DEF); +void element(Home,const IntSetArgs&,IntVar,int,IntVar,int,SetVar); +void element(Home,const IntSetArgs&,IntVar,SetVar); +void element(Home,const IntVarArgs&,IntVar,int,IntConLevel=ICL_DEF); +void element(Home,const IntVarArgs&,IntVar,int,IntVar,int,IntVar,IntConLevel=ICL_DEF); +void element(Home,const IntVarArgs&,IntVar,IntVar,IntConLevel=ICL_DEF); +void element(Home,const SetVarArgs&,IntVar,int,IntVar,int,SetVar); +void element(Home,const SetVarArgs&,IntVar,SetVar); +void element(Home,IntSharedArray,IntVar,BoolVar,IntConLevel=ICL_DEF); +void element(Home,IntSharedArray,IntVar,int,IntConLevel=ICL_DEF); +void element(Home,IntSharedArray,IntVar,int,IntVar,int,BoolVar,IntConLevel=ICL_DEF); +void element(Home,IntSharedArray,IntVar,int,IntVar,int,IntVar,IntConLevel=ICL_DEF); +void element(Home,IntSharedArray,IntVar,IntVar,IntConLevel=ICL_DEF); +void element(Home,SetOpType,const IntSetArgs&,SetVar,SetVar,const IntSet&=IntSet(Set::Limits::min,Set::Limits::max)); +void element(Home,SetOpType,const SetVarArgs&,SetVar,SetVar,const IntSet&=IntSet(Set::Limits::min,Set::Limits::max)); +void extensional(Home,const BoolVarArgs&,const TupleSet&,ExtensionalPropKind=EPK_DEF,IntConLevel=ICL_DEF); +void extensional(Home,const BoolVarArgs&,DFA,IntConLevel=ICL_DEF); +void extensional(Home,const IntVarArgs&,const TupleSet&,ExtensionalPropKind=EPK_DEF,IntConLevel=ICL_DEF); +void extensional(Home,const IntVarArgs&,DFA,IntConLevel=ICL_DEF); +void linear(Home,const BoolVarArgs&,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const BoolVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void linear(Home,const BoolVarArgs&,IntRelType,IntVar,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const BoolVarArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const BoolVarArgs&,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const BoolVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const BoolVarArgs&,IntRelType,IntVar,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const BoolVarArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const IntVarArgs&,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const IntVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const IntVarArgs&,IntRelType,IntVar,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntArgs&,const IntVarArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void linear(Home,const IntVarArgs&,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void linear(Home,const IntVarArgs&,IntRelType,IntVar,BoolVar,IntConLevel=ICL_DEF); +void linear(Home,const IntVarArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void max(Home,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void max(Home,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void max(Home,SetVar,IntVar); +void max(Home,SetVar,IntVar,BoolVar); +void min(Home,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void min(Home,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void min(Home,SetVar,IntVar); +void min(Home,SetVar,IntVar,BoolVar); +void mod(Home,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void mult(Home,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void nooverlap(Home,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void nooverlap(Home,const IntVarArgs&,const IntArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void nooverlap(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void nooverlap(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void notMax(Home,SetVar,IntVar); +void notMin(Home,SetVar,IntVar); +void path(Home,const IntArgs&,const IntVarArgs&,IntVar,IntVar,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void path(Home,const IntArgs&,const IntVarArgs&,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void path(Home,const IntArgs&,int,const IntVarArgs&,IntVar,IntVar,const IntVarArgs&,IntVar,IntConLevel=ICL_DEF); +void path(Home,const IntArgs&,int,const IntVarArgs&,IntVar,IntVar,IntVar,IntConLevel=ICL_DEF); +void path(Home,const IntVarArgs&,IntVar,IntVar,IntConLevel=ICL_DEF); +void path(Home,int,const IntVarArgs&,IntVar,IntVar,IntConLevel=ICL_DEF); +void precede(Home,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void precede(Home,const IntVarArgs&,int,int,IntConLevel=ICL_DEF); +void precede(Home,const SetVarArgs&,const IntArgs&); +void precede(Home,const SetVarArgs&,int,int); +void rel(Home,BoolOpType,const BoolVarArgs&,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,BoolOpType,const BoolVarArgs&,int,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,BoolOpType,BoolVar,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,BoolOpType,BoolVar,int,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,IntRelType,BoolVar,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,IntRelType,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,BoolVar,IntRelType,int,IntConLevel=ICL_DEF); +void rel(Home,const BoolVarArgs&,IntRelType,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,const BoolVarArgs&,IntRelType,const BoolVarArgs&,IntConLevel=ICL_DEF); +void rel(Home,const BoolVarArgs&,IntRelType,IntConLevel=ICL_DEF); +void rel(Home,const BoolVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void rel(Home,const IntSet&,SetOpType,SetVar,SetRelType,const IntSet&); +void rel(Home,const IntSet&,SetOpType,SetVar,SetRelType,SetVar); +void rel(Home,const IntVarArgs&,IntRelType,const IntVarArgs&,IntConLevel=ICL_DEF); +void rel(Home,const IntVarArgs&,IntRelType,IntConLevel=ICL_DEF); +void rel(Home,const IntVarArgs&,IntRelType,int,IntConLevel=ICL_DEF); +void rel(Home,const IntVarArgs&,IntRelType,IntVar,IntConLevel=ICL_DEF); +void rel(Home,IntVar,IntRelType,int,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,IntVar,IntRelType,int,IntConLevel=ICL_DEF); +void rel(Home,IntVar,IntRelType,IntVar,BoolVar,IntConLevel=ICL_DEF); +void rel(Home,IntVar,IntRelType,IntVar,IntConLevel=ICL_DEF); +void rel(Home,IntVar,IntRelType,SetVar); +void rel(Home,IntVar,SetRelType,SetVar); +void rel(Home,IntVar,SetRelType,SetVar,BoolVar); +void rel(Home,SetOpType,const IntVarArgs&,const IntSet&,SetVar); +void rel(Home,SetOpType,const IntVarArgs&,SetVar); +void rel(Home,SetOpType,const SetVarArgs&,const IntSet&,SetVar); +void rel(Home,SetOpType,const SetVarArgs&,SetVar); +void rel(Home,SetVar,IntRelType,IntVar); +void rel(Home,SetVar,SetOpType,const IntSet&,SetRelType,const IntSet&); +void rel(Home,SetVar,SetOpType,const IntSet&,SetRelType,SetVar); +void rel(Home,SetVar,SetOpType,SetVar,SetRelType,const IntSet&); +void rel(Home,SetVar,SetOpType,SetVar,SetRelType,SetVar); +void rel(Home,SetVar,SetRelType,IntVar); +void rel(Home,SetVar,SetRelType,IntVar,BoolVar); +void rel(Home,SetVar,SetRelType,SetVar); +void rel(Home,SetVar,SetRelType,SetVar,BoolVar); +void sequence(Home,const BoolVarArgs&,const IntSet&,int,int,int,IntConLevel=ICL_DEF); +void sequence(Home,const IntVarArgs&,const IntSet&,int,int,int,IntConLevel=ICL_DEF); +void sequence(Home,const SetVarArgs&); +void sequence(Home,const SetVarArgs&,SetVar); +void sorted(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void sorted(Home,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void sqr(Home,IntVar,IntVar,IntConLevel=ICL_DEF); +void sqrt(Home,IntVar,IntVar,IntConLevel=ICL_DEF); +void unary(Home,const IntVarArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void unary(Home,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void unary(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void unary(Home,const IntVarArgs&,const IntVarArgs&,const IntVarArgs&,IntConLevel=ICL_DEF); +void unary(Home,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,const BoolVarArgs&,IntConLevel=ICL_DEF); +void unary(Home,const TaskTypeArgs&,const IntVarArgs&,const IntArgs&,IntConLevel=ICL_DEF); +void unshare(Home,BoolVarArgs&,IntConLevel=ICL_DEF); +void unshare(Home,IntVarArgs&,IntConLevel=ICL_DEF); +void weights(Home,const IntArgs&,const IntArgs&,SetVar,IntVar); diff --git a/library/gecode/gecode_yap.cc b/library/gecode/gecode_yap.cc new file mode 100644 index 000000000..70d12b739 --- /dev/null +++ b/library/gecode/gecode_yap.cc @@ -0,0 +1,1045 @@ +// -*- c++ -*- +//============================================================================= +// Copyright (C) 2011 by Denys Duchier +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by the +// Free Software Foundation, either version 3 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 Lesser General Public License +// along with this program. If not, see . +//============================================================================= + +#include "gecode-common.icc" +#include +using namespace std; +using namespace generic_gecode; +using namespace Gecode; + +extern "C" +{ +#include "SWI-Stream.h" +#include "YapInterface.h" + + static YAP_opaque_tag_t gecode_space_tag; + static YAP_opaque_handler_t gecode_space_handler; + + static int gecode_space_fail_handler(void* p) + { + delete *(GenericSpace**)p; + return TRUE; + } + + static int + gecode_space_write_handler + (void *stream_, YAP_opaque_tag_t type, void *p, int flags) + { + IOSTREAM* stream = (IOSTREAM*) stream_; + Sfprintf(stream,"", p); + return TRUE; + } + + static YAP_Term gecode_term_from_space(GenericSpace* s) + { + YAP_Term term = + YAP_NewOpaqueObject(gecode_space_tag, sizeof(GenericSpace*)); + GenericSpace** ptr = + (GenericSpace**) YAP_OpaqueObjectFromTerm(term); + *ptr = s; + return term; + } + + static int gecode_new_space(void) + { + YAP_Term term = gecode_term_from_space(new GenericSpace); + return YAP_Unify(YAP_ARG1, term); + } + +#ifndef DISJUNCTOR + static inline GenericSpace* + gecode_Space_from_term(YAP_Term t) + { + return * (GenericSpace**) YAP_OpaqueObjectFromTerm(t); + } +#else + struct YapDisjunctor + { + GenericSpace* home; + Disjunctor disj; + YapDisjunctor(GenericSpace* home_) + : home(home_), disj(*home_) {} + }; + + static YAP_opaque_tag_t gecode_disjunctor_tag; + static YAP_opaque_handler_t gecode_disjunctor_handler; + static YAP_opaque_tag_t gecode_disjunctor_clause_tag; + static YAP_opaque_handler_t gecode_disjunctor_clause_handler; + + static inline Disjunctor& + gecode_Disjunctor_from_term(YAP_Term t) + { + return ((YapDisjunctor*) YAP_OpaqueObjectFromTerm(t))->disj; + } + + static inline YapDisjunctor& + gecode_YapDisjunctor_from_term(YAP_Term t) + { + return * (YapDisjunctor*) YAP_OpaqueObjectFromTerm(t); + } + + static inline Clause& + gecode_Clause_from_term(YAP_Term t) + { + return * (Clause*) YAP_OpaqueObjectFromTerm(t); + } + + static inline GenericSpace* + gecode_Space_from_term(YAP_Term t) + { + if (YAP_IsOpaqueObjectTerm(t, gecode_disjunctor_clause_tag)) + { + Clause& c = gecode_Clause_from_term(t); + return & (GenericSpace&) c; + } + return * (GenericSpace**) YAP_OpaqueObjectFromTerm(t); + } +#endif + + static YAP_opaque_tag_t gecode_engine_tag; + static YAP_opaque_handler_t gecode_engine_handler; + + static int gecode_new_engine(void) + { + YAP_Term arg1 = YAP_ARG1; + YAP_Term arg2 = YAP_ARG2; + GenericSpace* space = gecode_Space_from_term(arg1); + GenericEngine* engine = space->new_engine(); + YAP_Term y_engine = + YAP_NewOpaqueObject(gecode_engine_tag, sizeof(GenericEngine*)); + GenericEngine** ptr = + (GenericEngine**) YAP_OpaqueObjectFromTerm(y_engine); + *ptr = engine; + return YAP_Unify(arg2, y_engine); + } + + static inline GenericEngine* + gecode_engine_from_term(YAP_Term t) + { + return * (GenericEngine**) YAP_OpaqueObjectFromTerm(t); + } + + static int gecode_engine_fail_handler(void* p) + { + delete *(GenericEngine**)p; + return TRUE; + } + + static int + gecode_engine_write_handler + (void *stream_, YAP_opaque_tag_t type, void *p, int flags) + { + IOSTREAM* stream = (IOSTREAM*) stream_; + Sfprintf(stream,"", p); + return TRUE; + } + + static int gecode_engine_search(void) + { + GenericEngine* engine = gecode_engine_from_term(YAP_ARG1); + GenericSpace* space = engine->next(); + if (space) + { + YAP_Term term = gecode_term_from_space(space); + return YAP_Unify(YAP_ARG2, term); + } + else YAP_cut_fail(); + } + +#ifdef DISJUNCTOR + static int gecode_new_disjunctor(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + YAP_Term term = + YAP_NewOpaqueObject(gecode_disjunctor_tag, sizeof(YapDisjunctor)); + new (YAP_OpaqueObjectFromTerm(term)) YapDisjunctor(space); + return YAP_Unify(result, term); + } + + static int + gecode_disjunctor_write_handler + (void *stream_, YAP_opaque_tag_t type, void *p, int flags) + { + IOSTREAM* stream = (IOSTREAM*) stream_; + Sfprintf(stream,"", p); + return TRUE; + } + + static int gecode_new_clause(void) + { + YAP_Term result = YAP_ARG1; + YapDisjunctor& disj = gecode_YapDisjunctor_from_term(YAP_ARG2); + YAP_Term term = + YAP_NewOpaqueObject(gecode_disjunctor_clause_tag, sizeof(Clause)); + new (YAP_OpaqueObjectFromTerm(term)) Clause(*disj.home,disj.disj); + return YAP_Unify(result, term); + } + + static int + gecode_clause_write_handler + (void *stream_, YAP_opaque_tag_t type, void *p, int flags) + { + IOSTREAM* stream = (IOSTREAM*) stream_; + Sfprintf(stream,"", p); + return TRUE; + } + + static IntVar gecode_IntVar_from_term(GenericSpace*,YAP_Term); + static BoolVar gecode_BoolVar_from_term(GenericSpace*,YAP_Term); + static SetVar gecode_SetVar_from_term(GenericSpace*,YAP_Term); + + static int gecode_clause_intvar_forward(void) + { + Clause& clause = gecode_Clause_from_term(YAP_ARG1); + GenericSpace* outer = clause.generic_parent(); + GenericSpace* inner = clause.generic_space(); + IntVar outer_var = gecode_IntVar_from_term(outer, YAP_ARG2); + IntVar inner_var = gecode_IntVar_from_term(inner, YAP_ARG3); + clause.forward(outer_var,inner_var); + return TRUE; + } + + static int gecode_clause_boolvar_forward(void) + { + Clause& clause = gecode_Clause_from_term(YAP_ARG1); + GenericSpace* outer = clause.generic_parent(); + GenericSpace* inner = clause.generic_space(); + BoolVar outer_var = gecode_BoolVar_from_term(outer, YAP_ARG2); + BoolVar inner_var = gecode_BoolVar_from_term(inner, YAP_ARG3); + clause.forward(outer_var,inner_var); + return TRUE; + } + + static int gecode_clause_setvar_forward(void) + { + Clause& clause = gecode_Clause_from_term(YAP_ARG1); + GenericSpace* outer = clause.generic_parent(); + GenericSpace* inner = clause.generic_space(); + SetVar outer_var = gecode_SetVar_from_term(outer, YAP_ARG2); + SetVar inner_var = gecode_SetVar_from_term(inner, YAP_ARG3); + clause.forward(outer_var,inner_var); + return TRUE; + } +#endif + + static int gecode_new_intvar_from_bounds(void) + { + YAP_Term ivar = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int lo = YAP_IntOfTerm(YAP_ARG3); + int hi = YAP_IntOfTerm(YAP_ARG4); + int i = space->new_ivar(lo, hi); + YAP_Term y_i = YAP_MkIntTerm(i); + return YAP_Unify(ivar, y_i); + } + + static int + gecode_list_length(YAP_Term l) + { + int n = 0; + while (YAP_IsPairTerm(l)) + { + n += 1; + l = YAP_TailOfTerm(l); + } + return n; + } + + static IntSet + gecode_IntSet_from_term(YAP_Term specs) + { + int n = gecode_list_length(specs); + int r[n][2]; + int i = 0; + while (YAP_IsPairTerm(specs)) + { + YAP_Term head = YAP_HeadOfTerm(specs); + specs = YAP_TailOfTerm(specs); + r[i][0] = YAP_IntOfTerm(YAP_ArgOfTerm(1, head)); + r[i][1] = YAP_IntOfTerm(YAP_ArgOfTerm(2, head)); + i += 1; + } + return IntSet(r, n); + } + + static int gecode_new_intvar_from_intset(void) + { + YAP_Term ivar = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + YAP_Term specs = YAP_ARG3; + IntSet iset = gecode_IntSet_from_term(specs); + int i = space->new_ivar(iset); + return YAP_Unify(ivar, YAP_MkIntTerm(i)); + } + + static int gecode_new_boolvar(void) + { + YAP_Term bvar = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int i = space->new_bvar(); + return YAP_Unify(bvar, YAP_MkIntTerm(i)); + } + + static int gecode_new_setvar_1(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + int LubMin = YAP_IntOfTerm(YAP_ARG5); + int LubMax = YAP_IntOfTerm(YAP_ARG6); + int CardMin= YAP_IntOfTerm(YAP_ARG7); + int CardMax= YAP_IntOfTerm(YAP_ARG8); + int idx = space->new_svar(GlbMin,GlbMax,LubMin,LubMax,CardMin,CardMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_2(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + int LubMin = YAP_IntOfTerm(YAP_ARG5); + int LubMax = YAP_IntOfTerm(YAP_ARG6); + int CardMin= YAP_IntOfTerm(YAP_ARG7); + int idx = space->new_svar(GlbMin,GlbMax,LubMin,LubMax,CardMin); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_3(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + int LubMin = YAP_IntOfTerm(YAP_ARG5); + int LubMax = YAP_IntOfTerm(YAP_ARG6); + int idx = space->new_svar(GlbMin,GlbMax,LubMin,LubMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_4(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + int LubMin = YAP_IntOfTerm(YAP_ARG4); + int LubMax = YAP_IntOfTerm(YAP_ARG5); + int CardMin = YAP_IntOfTerm(YAP_ARG6); + int CardMax = YAP_IntOfTerm(YAP_ARG7); + int idx = space->new_svar(Glb,LubMin,LubMax,CardMin,CardMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_5(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + int LubMin = YAP_IntOfTerm(YAP_ARG4); + int LubMax = YAP_IntOfTerm(YAP_ARG5); + int CardMin = YAP_IntOfTerm(YAP_ARG6); + int idx = space->new_svar(Glb,LubMin,LubMax,CardMin); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_6(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + int LubMin = YAP_IntOfTerm(YAP_ARG4); + int LubMax = YAP_IntOfTerm(YAP_ARG5); + int idx = space->new_svar(Glb,LubMin,LubMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_7(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG5); + int CardMin = YAP_IntOfTerm(YAP_ARG6); + int CardMax = YAP_IntOfTerm(YAP_ARG7); + int idx = space->new_svar(GlbMin,GlbMax,Lub,CardMin,CardMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_8(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG5); + int CardMin = YAP_IntOfTerm(YAP_ARG6); + int idx = space->new_svar(GlbMin,GlbMax,Lub,CardMin); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_9(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + int GlbMin = YAP_IntOfTerm(YAP_ARG3); + int GlbMax = YAP_IntOfTerm(YAP_ARG4); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG5); + int idx = space->new_svar(GlbMin,GlbMax,Lub); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_10(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG4); + int CardMin = YAP_IntOfTerm(YAP_ARG5); + int CardMax = YAP_IntOfTerm(YAP_ARG6); + int idx = space->new_svar(Glb,Lub,CardMin,CardMax); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_11(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG4); + int CardMin = YAP_IntOfTerm(YAP_ARG5); + int idx = space->new_svar(Glb,Lub,CardMin); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_new_setvar_12(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntSet Glb = gecode_IntSet_from_term(YAP_ARG3); + IntSet Lub = gecode_IntSet_from_term(YAP_ARG4); + int idx = space->new_svar(Glb,Lub); + return YAP_Unify(result, YAP_MkIntTerm(idx)); + } + + static int gecode_space_minimize(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + int i = YAP_IntOfTerm(YAP_ARG2); + space->minimize(i); + return TRUE; + } + + static int gecode_space_maximize(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + int i = YAP_IntOfTerm(YAP_ARG2); + space->maximize(i); + return TRUE; + } + + static int gecode_space_minimize_ratio(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + int i = YAP_IntOfTerm(YAP_ARG2); + int j = YAP_IntOfTerm(YAP_ARG3); + space->minimize(i,j); + return TRUE; + } + + static int gecode_space_maximize_ratio(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + int i = YAP_IntOfTerm(YAP_ARG2); + int j = YAP_IntOfTerm(YAP_ARG3); + space->maximize(i,j); + return TRUE; + } + + static IntVar + gecode_IntVar_from_term(GenericSpace* space, YAP_Term x) + { + int i = YAP_IntOfTerm(x); + return space->get_ivar(i); + } + + static BoolVar + gecode_BoolVar_from_term(GenericSpace* space, YAP_Term x) + { + int i = YAP_IntOfTerm(x); + return space->get_bvar(i); + } + + static SetVar + gecode_SetVar_from_term(GenericSpace* space, YAP_Term x) + { + int i = YAP_IntOfTerm(x); + return space->get_svar(i); + } + + static IntVarArgs + gecode_IntVarArgs_from_term(GenericSpace* space, YAP_Term l) + { + int n = gecode_list_length(l); + IntVarArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + int idx = YAP_IntOfTerm(YAP_HeadOfTerm(l)); + v[i] = space->get_ivar(idx); + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static BoolVarArgs + gecode_BoolVarArgs_from_term(GenericSpace* space, YAP_Term l) + { + int n = gecode_list_length(l); + BoolVarArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + int idx = YAP_IntOfTerm(YAP_HeadOfTerm(l)); + v[i] = space->get_bvar(idx); + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static SetVarArgs + gecode_SetVarArgs_from_term(GenericSpace* space, YAP_Term l) + { + int n = gecode_list_length(l); + SetVarArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + int idx = YAP_IntOfTerm(YAP_HeadOfTerm(l)); + v[i] = space->get_svar(idx); + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static IntArgs + gecode_IntArgs_from_term(YAP_Term l) + { + int n = gecode_list_length(l); + IntArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + int idx = YAP_IntOfTerm(YAP_HeadOfTerm(l)); + v[i] = idx; + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static IntSetArgs + gecode_IntSetArgs_from_term(YAP_Term l) + { + int n = gecode_list_length(l); + IntSetArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + IntSet s = gecode_IntSet_from_term(YAP_HeadOfTerm(l)); + v[i] = s; + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static TaskType gecode_TaskType_from_term(YAP_Term); + + static TaskTypeArgs + gecode_TaskTypeArgs_from_term(YAP_Term l) + { + int n = gecode_list_length(l); + TaskTypeArgs v(n); + int i = 0; + while (YAP_IsPairTerm(l)) + { + TaskType tt = gecode_TaskType_from_term(YAP_HeadOfTerm(l)); + v[i] = tt; + l = YAP_TailOfTerm(l); + i += 1; + } + return v; + } + + static YAP_Term gecode_TRUE; + static YAP_Term gecode_FALSE; + + static bool + gecode_bool_from_term(YAP_Term X) + { + if (X==gecode_TRUE) return true; + if (X==gecode_FALSE) return false; + cerr << "this should never happen" << endl; exit(1); + } + + // INFO ON INTVARS + static int gecode_intvar_assigned(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG2); + return (x.assigned()) ? TRUE : FALSE; + } + + static int gecode_intvar_min(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.min())); + } + + static int gecode_intvar_max(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.max())); + } + + static int gecode_intvar_med(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.med())); + } + + static int gecode_intvar_val(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.val())); + } + + static int gecode_intvar_size(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.size())); + } + + static int gecode_intvar_width(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.width())); + } + + static int gecode_intvar_regret_min(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.regret_min())); + } + + static int gecode_intvar_regret_max(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + IntVar x = gecode_IntVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.regret_max())); + } + + // INFO ON BOOLVARS + static int gecode_boolvar_assigned(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG2); + return (x.assigned()) ? TRUE : FALSE; + } + + static int gecode_boolvar_min(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.min())); + } + + static int gecode_boolvar_max(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.max())); + } + + static int gecode_boolvar_med(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.med())); + } + + static int gecode_boolvar_val(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.val())); + } + + static int gecode_boolvar_size(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.size())); + } + + static int gecode_boolvar_width(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.width())); + } + + static int gecode_boolvar_regret_min(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.regret_min())); + } + + static int gecode_boolvar_regret_max(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.regret_max())); + } + + // INFO ON SETVARS + static int gecode_setvar_assigned(void) + { + GenericSpace* space = gecode_Space_from_term(YAP_ARG1); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG2); + return (x.assigned()) ? TRUE : FALSE; + } + + static int gecode_setvar_glbSize(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.glbSize())); + } + + static int gecode_setvar_lubSize(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.lubSize())); + } + + static int gecode_setvar_unknownSize(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.unknownSize())); + } + + static int gecode_setvar_cardMin(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.cardMin())); + } + + static int gecode_setvar_cardMax(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.cardMax())); + } + + static int gecode_setvar_lubMin(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.lubMin())); + } + + static int gecode_setvar_lubMax(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.lubMax())); + } + + static int gecode_setvar_glbMin(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.glbMin())); + } + + static int gecode_setvar_glbMax(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + return YAP_Unify(result, YAP_MkIntTerm(x.glbMax())); + } + + static YAP_Functor gecode_COMMA2; + + static int gecode_setvar_glb_ranges(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + int n = 0; + { SetVarGlbRanges it(x); while (it()) { ++n; ++it; } } + int min[n], max[n]; + { SetVarGlbRanges it(x); int i=0; + while (it()) { min[i]=it.min(); max[i]=it.max(); ++it; ++i; } } + YAP_Term lst = YAP_TermNil(); + for (;n--;) + { + YAP_Term args[2]; + args[0] = YAP_MkIntTerm(min[n]); + args[1] = YAP_MkIntTerm(max[n]); + YAP_Term range = YAP_MkApplTerm(gecode_COMMA2,2,args); + lst = YAP_MkPairTerm(range,lst); + } + return YAP_Unify(result,lst); + } + + static int gecode_setvar_lub_ranges(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + int n = 0; + { SetVarLubRanges it(x); while (it()) { ++n; ++it; } } + int min[n], max[n]; + { SetVarLubRanges it(x); int i=0; + while (it()) { min[i]=it.min(); max[i]=it.max(); ++it; ++i; } } + YAP_Term lst = YAP_TermNil(); + for (;n--;) + { + YAP_Term args[2]; + args[0] = YAP_MkIntTerm(min[n]); + args[1] = YAP_MkIntTerm(max[n]); + YAP_Term range = YAP_MkApplTerm(gecode_COMMA2,2,args); + lst = YAP_MkPairTerm(range,lst); + } + return YAP_Unify(result,lst); + } + + static int gecode_setvar_unknown_ranges(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + int n = 0; + { SetVarUnknownRanges it(x); while (it()) { ++n; ++it; } } + int min[n], max[n]; + { SetVarUnknownRanges it(x); int i=0; + while (it()) { min[i]=it.min(); max[i]=it.max(); ++it; ++i; } } + YAP_Term lst = YAP_TermNil(); + for (;n--;) + { + YAP_Term args[2]; + args[0] = YAP_MkIntTerm(min[n]); + args[1] = YAP_MkIntTerm(max[n]); + YAP_Term range = YAP_MkApplTerm(gecode_COMMA2,2,args); + lst = YAP_MkPairTerm(range,lst); + } + return YAP_Unify(result,lst); + } + + static int gecode_setvar_glb_values(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + YAP_Term elems[x.glbSize()]; + SetVarGlbValues it(x); + int n = 0; + while (it()) { elems[n] = YAP_MkIntTerm(it.val()); ++it; ++n; } + YAP_Term lst = YAP_TermNil(); + for (;n--;) lst = YAP_MkPairTerm(elems[n],lst); + return YAP_Unify(result,lst); + } + + static int gecode_setvar_lub_values(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + YAP_Term elems[x.glbSize()]; + SetVarLubValues it(x); + int n = 0; + while (it()) { elems[n] = YAP_MkIntTerm(it.val()); ++it; ++n; } + YAP_Term lst = YAP_TermNil(); + for (;n--;) lst = YAP_MkPairTerm(elems[n],lst); + return YAP_Unify(result,lst); + } + + static int gecode_setvar_unknown_values(void) + { + YAP_Term result = YAP_ARG1; + GenericSpace* space = gecode_Space_from_term(YAP_ARG2); + SetVar x = gecode_SetVar_from_term(space, YAP_ARG3); + YAP_Term elems[x.glbSize()]; + SetVarUnknownValues it(x); + int n = 0; + while (it()) { elems[n] = YAP_MkIntTerm(it.val()); ++it; ++n; } + YAP_Term lst = YAP_TermNil(); + for (;n--;) lst = YAP_MkPairTerm(elems[n],lst); + return YAP_Unify(result,lst); + } + +#define gecode_int_from_term YAP_IntOfTerm + +#include "gecode_yap_cc_forward_auto_generated.icc" +#include "gecode_yap_cc_impl_auto_generated.icc" + + void gecode_init(void) + { + { YAP_Atom X= YAP_LookupAtom("true"); + gecode_TRUE = YAP_MkAtomTerm(X); + YAP_AtomGetHold(X); } + { YAP_Atom X= YAP_LookupAtom("false"); + gecode_FALSE = YAP_MkAtomTerm(X); + YAP_AtomGetHold(X); } + { YAP_Atom X= YAP_LookupAtom(","); + YAP_AtomGetHold(X); + gecode_COMMA2 = YAP_MkFunctor(X,2); } +#include "gecode_yap_cc_init_auto_generated.icc" + // opaque spaces + gecode_space_handler.fail_handler = gecode_space_fail_handler; + gecode_space_handler.write_handler = gecode_space_write_handler; + gecode_space_tag = YAP_NewOpaqueType(&gecode_space_handler); + YAP_UserCPredicate("gecode_new_space", gecode_new_space, 1); + // opaque engines + gecode_engine_handler.fail_handler = gecode_engine_fail_handler; + gecode_engine_handler.write_handler = gecode_engine_write_handler; + gecode_engine_tag = YAP_NewOpaqueType(&gecode_engine_handler); + YAP_UserCPredicate("gecode_new_engine", gecode_new_engine, 2); +#ifdef DISJUNCTOR + // opaque disjunctors and clauses + gecode_disjunctor_handler.write_handler = gecode_disjunctor_write_handler; + gecode_disjunctor_tag = YAP_NewOpaqueType(&gecode_disjunctor_handler); + gecode_disjunctor_clause_handler.write_handler = gecode_clause_write_handler; + gecode_disjunctor_clause_tag = + YAP_NewOpaqueType(&gecode_disjunctor_clause_handler); + YAP_UserCPredicate("gecode_new_disjunctor", gecode_new_disjunctor, 2); + YAP_UserCPredicate("gecode_new_clause", gecode_new_clause, 2); + YAP_UserCPredicate("gecode_clause_intvar_forward", gecode_clause_intvar_forward, 3); + YAP_UserCPredicate("gecode_clause_boolvar_forward", gecode_clause_boolvar_forward, 3); + YAP_UserCPredicate("gecode_clause_setvar_forward", gecode_clause_setvar_forward, 3); +#endif + // backtracking search using an engine + YAP_UserBackCutCPredicate("gecode_engine_search", + gecode_engine_search, gecode_engine_search, + NULL, 2, 0); + // creating variables + YAP_UserCPredicate("gecode_new_intvar_from_bounds", + gecode_new_intvar_from_bounds, 4); + YAP_UserCPredicate("gecode_new_intvar_from_intset", + gecode_new_intvar_from_intset, 3); + YAP_UserCPredicate("gecode_new_boolvar", gecode_new_boolvar, 2); + YAP_UserCPredicate("gecode_new_setvar_1", gecode_new_setvar_1, 8); + YAP_UserCPredicate("gecode_new_setvar_2", gecode_new_setvar_2, 7); + YAP_UserCPredicate("gecode_new_setvar_3", gecode_new_setvar_3, 6); + YAP_UserCPredicate("gecode_new_setvar_4", gecode_new_setvar_4, 7); + YAP_UserCPredicate("gecode_new_setvar_5", gecode_new_setvar_5, 6); + YAP_UserCPredicate("gecode_new_setvar_6", gecode_new_setvar_6, 5); + YAP_UserCPredicate("gecode_new_setvar_7", gecode_new_setvar_7, 7); + YAP_UserCPredicate("gecode_new_setvar_8", gecode_new_setvar_8, 6); + YAP_UserCPredicate("gecode_new_setvar_9", gecode_new_setvar_9, 5); + YAP_UserCPredicate("gecode_new_setvar_10", gecode_new_setvar_10, 6); + YAP_UserCPredicate("gecode_new_setvar_11", gecode_new_setvar_11, 5); + YAP_UserCPredicate("gecode_new_setvar_12", gecode_new_setvar_12, 4); + YAP_UserCPredicate("gecode_space_minimize", gecode_space_minimize, 2); + YAP_UserCPredicate("gecode_space_maximize", gecode_space_maximize, 2); + YAP_UserCPredicate("gecode_space_minimize_ratio", gecode_space_minimize_ratio, 3); + YAP_UserCPredicate("gecode_space_maximize_ratio", gecode_space_maximize_ratio, 3); + // INFO ON INTVARS + YAP_UserCPredicate("gecode_intvar_assigned", gecode_intvar_assigned, 2); + YAP_UserCPredicate("gecode_intvar_min", gecode_intvar_min, 3); + YAP_UserCPredicate("gecode_intvar_max", gecode_intvar_max, 3); + YAP_UserCPredicate("gecode_intvar_med", gecode_intvar_med, 3); + YAP_UserCPredicate("gecode_intvar_val", gecode_intvar_val, 3); + YAP_UserCPredicate("gecode_intvar_size", gecode_intvar_size, 3); + YAP_UserCPredicate("gecode_intvar_width", gecode_intvar_width, 3); + YAP_UserCPredicate("gecode_intvar_regret_min", gecode_intvar_regret_min, 3); + YAP_UserCPredicate("gecode_intvar_regret_max", gecode_intvar_regret_max, 3); + // INFO ON BOOLVARS + YAP_UserCPredicate("gecode_boolvar_assigned", gecode_boolvar_assigned, 2); + YAP_UserCPredicate("gecode_boolvar_min", gecode_boolvar_min, 3); + YAP_UserCPredicate("gecode_boolvar_max", gecode_boolvar_max, 3); + YAP_UserCPredicate("gecode_boolvar_med", gecode_boolvar_med, 3); + YAP_UserCPredicate("gecode_boolvar_val", gecode_boolvar_val, 3); + YAP_UserCPredicate("gecode_boolvar_size", gecode_boolvar_size, 3); + YAP_UserCPredicate("gecode_boolvar_width", gecode_boolvar_width, 3); + YAP_UserCPredicate("gecode_boolvar_regret_min", gecode_boolvar_regret_min, 3); + YAP_UserCPredicate("gecode_boolvar_regret_max", gecode_boolvar_regret_max, 3); + // INFO ON SETVARS + YAP_UserCPredicate("gecode_setvar_assigned", gecode_setvar_assigned, 2); + YAP_UserCPredicate("gecode_setvar_glbSize", gecode_setvar_glbSize, 3); + YAP_UserCPredicate("gecode_setvar_lubSize", gecode_setvar_lubSize, 3); + YAP_UserCPredicate("gecode_setvar_unknownSize", gecode_setvar_unknownSize, 3); + YAP_UserCPredicate("gecode_setvar_cardMin", gecode_setvar_cardMin, 3); + YAP_UserCPredicate("gecode_setvar_cardMax", gecode_setvar_cardMax, 3); + YAP_UserCPredicate("gecode_setvar_lubMin", gecode_setvar_lubMin, 3); + YAP_UserCPredicate("gecode_setvar_lubMax", gecode_setvar_lubMax, 3); + YAP_UserCPredicate("gecode_setvar_glbMin", gecode_setvar_glbMin, 3); + YAP_UserCPredicate("gecode_setvar_glbMax", gecode_setvar_glbMax, 3); + YAP_UserCPredicate("gecode_setvar_glb_ranges", gecode_setvar_glb_ranges, 3); + YAP_UserCPredicate("gecode_setvar_lub_ranges", gecode_setvar_lub_ranges, 3); + YAP_UserCPredicate("gecode_setvar_unknown_ranges", gecode_setvar_unknown_ranges, 3); + YAP_UserCPredicate("gecode_setvar_glb_values", gecode_setvar_glb_values, 3); + YAP_UserCPredicate("gecode_setvar_lub_values", gecode_setvar_lub_values, 3); + YAP_UserCPredicate("gecode_setvar_unknown_values", gecode_setvar_unknown_values, 3); + } +} diff --git a/library/gecode/gecode_yap_hand_written.yap b/library/gecode/gecode_yap_hand_written.yap new file mode 100644 index 000000000..bc11628a8 --- /dev/null +++ b/library/gecode/gecode_yap_hand_written.yap @@ -0,0 +1,746 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +:- module(gecode, [(:=)/2, op(500, xfx, ':='), + (+=)/2, op(500, xfx, '+=')]). + +:- op(500, xfx, ':='). +:- op(500, xfx, '+='). +:- load_foreign_files([gecode_yap],[],gecode_init). + +is_int(X,Y) :- integer(X), Y=X. +is_int(X) :- integer(X). + +is_bool_(true,true). +is_bool_(false,false). +is_bool(X,Y) :- nonvar(X), Y=X. +is_bool(X) :- is_bool(X,_). + +is_IntVar_('IntVar'(I),I) :- integer(I). +is_BoolVar_('BoolVar'(I),I) :- integer(I). +is_SetVar_('SetVar'(I),I) :- integer(I). + +is_IntVar(X,I) :- nonvar(X), is_IntVar_(X,I). +is_BoolVar(X,I) :- nonvar(X), is_BoolVar_(X,I). +is_SetVar(X,I) :- nonvar(X), is_SetVar_(X,I). + +is_IntVar(X) :- is_IntVar(X,_). +is_BoolVar(X) :- is_BoolVar(X,_). +is_SetVar(X) :- is_SetVar(X,_). + +is_IntVarArgs_([],[]). +is_IntVarArgs_([H|T],[H2|T2]) :- is_IntVar(H,H2), is_IntVarArgs(T,T2). +is_IntVarArgs(X,Y) :- nonvar(X), is_IntVarArgs_(X,Y). +is_IntVarArgs(X) :- \+ \+ is_IntVarArgs(X,_). + +is_BoolVarArgs_([],[]). +is_BoolVarArgs_([H|T],[H2|T2]) :- is_BoolVar(H,H2), is_BoolVarArgs(T,T2). +is_BoolVarArgs(X,Y) :- nonvar(X), is_BoolVarArgs_(X,Y). +is_BoolVarArgs(X) :- \+ \+ is_BoolVarArgs(X,_). + +is_SetVarArgs_([],[]). +is_SetVarArgs_([H|T],[H2|T2]) :- is_SetVar(H,H2), is_SetVarArgs(T,T2). +is_SetVarArgs(X,Y) :- nonvar(X), is_SetVarArgs_(X,Y). +is_SetVarArgs(X) :- \+ \+ is_SetVarArgs(X,_). + +is_IntArgs_([],[]). +is_IntArgs_([H|T],[H|T2]) :- integer(H), is_IntArgs(T,T2). +is_IntArgs(X,Y) :- nonvar(X), is_IntArgs_(X,Y). +is_IntArgs(X) :- \+ \+ is_IntArgs(X,_). + +is_IntSharedArray(X) :- is_IntArgs(X). +is_IntSharedArray(X,Y) :- is_IntArgs(X,Y). + +is_TaskTypeArgs_([],[]). +is_TaskTypeArgs_([H|T],[H2|T2]) :- is_TaskType(H,H2), is_TaskTypeArgs(T,T2). +is_TaskTypeArgs(X,Y) :- nonvar(X), is_TaskTypeArgs_(X,Y). +is_TaskTypeArgs(X) :- \+ \+ is_TaskTypeArgs(X,_). + +is_IntSet_('IntSet'(L),L). +is_IntSet(X,Y) :- nonvar(X), is_IntSet_(X,Y). +is_IntSet(X) :- is_IntSet(X,_). + +is_IntSetArgs_([],[]). +is_IntSetArgs_([H|T],[H2|T2]) :- is_IntSet(H,H2), is_IntSetArgs(T,T2). +is_IntSetArgs(X,Y) :- nonvar(X), is_IntSetArgs_(X,Y). +is_IntSetArgs(X) :- \+ \+ is_IntSetArgs(X,_). + +new_intset(X,I,J) :- intset(X,I,J). +new_intset(X,L) :- intset(X,L). + +intset(X, I, J) :- + integer(I), + integer(J), + X='IntSet'([(I,J)]). +intset(X, L) :- + is_list_of_intset_specs(L,L2), + X='IntSet'(L2). + +is_list_of_intset_specs(X,Y) :- + nonvar(X), is_list_of_intset_specs_(X,Y). +is_list_of_intset_specs_([],[]). +is_list_of_intset_specs_([H|T],[H2|T2]) :- + is_intset_spec(H,H2), + is_list_of_intset_specs(T,T2). + +is_intset_spec(X,Y) :- nonvar(X), is_intset_spec_(X,Y). +is_intset_spec_((I,J),(I,J)) :- !, integer(I), integer(J). +is_intset_spec_(I,(I,I)) :- integer(I). + +assert_var(X,Y) :- + var(X) -> X=Y; throw(gecode_error(expected(var))). +assert_is_int(X,Y) :- + integer(X) -> X=Y ; throw(gecode_error(expected(int))). +assert_is_Space(X,Y) :- + is_Space(X,Y) -> true ; throw(gecode_error(expected(space))). +assert_is_IntSet(X,Y) :- + is_IntSet(X,Y) -> true ; throw(gecode_error(expected(intset))). +assert_is_IntVar(X,Y) :- + is_IntVar(X,Y) -> true ; throw(gecode_error(expected(intvar))). +assert_is_BoolVar(X,Y) :- + is_BoolVar(X,Y) -> true ; throw(gecode_error(expected(boolvar))). +assert_is_SetVar(X,Y) :- + is_SetVar(X,Y) -> true ; throw(gecode_error(expected(setvar))). +assert_is_IntArgs(X,Y) :- + is_IntArgs(X,Y) -> true ; throw(gecode_error(expected(intargs))). +assert_is_IntVarArgs(X,Y) :- + is_IntVarArgs(X,Y) -> true ; throw(gecode_error(expected(intvarargs))). +assert_is_BoolVarArgs(X,Y) :- + is_BoolVarArgs(X,Y) -> true ; throw(gecode_error(expected(boolvarargs))). +assert_is_SetVarArgs(X,Y) :- + is_SetVarArgs(X,Y) -> true ; throw(gecode_error(expected(setvarargs))). + +assert_var(X) :- assert_var(X,_). +assert_is_int(X) :- assert_is_int(X,_). +assert_is_Space(X) :- assert_is_Space(X,_). +assert_is_IntSet(X) :- assert_is_IntSet(X,_). +assert_is_IntVar(X) :- assert_is_IntVar(X,_). +assert_is_BoolVar(X) :- assert_is_BoolVar(X,_). +assert_is_SetVar(X) :- assert_is_SetVar(X,_). +assert_is_IntArgs(X) :- assert_is_IntArgs(X,_). +assert_is_IntVarArgs(X) :- assert_is_IntVarArgs(X,_). +assert_is_BoolVarArgs(X) :- assert_is_BoolVarArgs(X,_). +assert_is_SetVarArgs(X) :- assert_is_SetVarArgs(X,_). + +new_space(Space) :- + assert_var(Space), + gecode_new_space(Space_), + Space='Space'(Space_). + +is_Space_('Space'(X),X). +is_Space(X,Y) :- nonvar(X), is_Space_(X,Y). +is_Space(X) :- is_Space(X,_). + +%% AUTOGENERATE ALL VARIANTS LATER! + +new_intvars([], Space, Lo, Hi). +new_intvars([IVar|IVars], Space, Lo, Hi) :- + new_intvar(IVar, Space, Lo, Hi), + new_intvars(IVars, Space, Lo, Hi). + +new_intvars([], Space, IntSet). +new_intvars([IVar|IVars], Space, IntSet) :- + new_intvar(IVar, Space, IntSet), + new_intvars(IVars, Space, IntSet). + +new_boolvars([], Space). +new_boolvars([BVar|BVars], Space) :- + new_boolvar(BVar, Space), + new_boolvars(BVars, Space). + +new_setvars([], Space, X1, X2, X3, X4, X5, X6). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4, X5, X6) :- + new_setvar(SVar, Space, X1, X2, X3, X4, X5, X6), + new_setvars(SVars, Space, X1, X2, X3, X4, X5, X6). + +new_setvars([], Space, X1, X2, X3, X4, X5). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4, X5) :- + new_setvar(SVar, Space, X1, X2, X3, X4, X5), + new_setvars(SVars, Space, X1, X2, X3, X4, X5). + +new_setvars([], Space, X1, X2, X3, X4). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4) :- + new_setvar(SVar, Space, X1, X2, X3, X4), + new_setvars(SVars, Space, X1, X2, X3, X4). + +new_setvars([], Space, X1, X2, X3). +new_setvars([SVar|SVars], Space, X1, X2, X3) :- + new_setvar(SVar, Space, X1, X2, X3), + new_setvars(SVars, Space, X1, X2, X3). + +new_setvars([], Space, X1, X2). +new_setvars([SVar|SVars], Space, X1, X2) :- + new_setvar(SVar, Space, X1, X2), + new_setvars(SVars, Space, X1, X2). + +%% AUTOGENERATE LATER + +assert_integer(X) :- assert_is_int(X). + +new_intvar(IVar, Space, Lo, Hi) :- !, + assert_var(IVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(Lo), + assert_integer(Hi), + gecode_new_intvar_from_bounds(Idx,Space_,Lo,Hi), + IVar='IntVar'(Idx). +new_intvar(IVar, Space, IntSet) :- !, + assert_var(IVar), + assert_is_Space_or_Clause(Space,Space_), + assert_is_IntSet(IntSet, L), + gecode_new_intvar_from_intset(Idx,Space_,L), + IVar='IntVar'(Idx). + +new_boolvar(BVar, Space) :- !, + assert_var(BVar), + assert_is_Space_or_Clause(Space,Space_), + gecode_new_boolvar(Idx,Space_), + BVar='BoolVar'(Idx). + +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin,CardMax) 6 new_setvar_1 +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin) 5 new_setvar_2 +%% (GlbMin,GlbMax,LubMin,LubMax) 4 new_setvar_3 +%% (Glb,LubMin,LubMax,CardMin,CardMax) 5 new_setvar_4 +%% (Glb,LubMin,LubMax,CardMin) 4 new_setvar_5 +%% (Glb,LubMin,LubMax) 3 new_setvar_6 +%% (GlbMin,GlbMax,Lub,CardMin,CardMax) 5 new_setvar_7 +%% (GlbMin,GlbMax,Lub,CardMin) 4 new_setvar_8 +%% (GlbMin,GlbMax,Lub) 3 new_setvar_9 +%% (Glb,Lub,CardMin,CardMax) 4 new_setvar_10 +%% (Glb,Lub,CardMin) 3 new_setvar_11 +%% (Glb,Lub) 2 new_setvar_12 + +%% 6 arguments +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin,CardMax) 6 new_setvar_1 +new_setvar(SVar, Space, GlbMin, GlbMax, LubMin, LubMax, CardMin, CardMax) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(GlbMin), + assert_integer(GlbMax), + assert_integer(LubMin), + assert_integer(LubMax), + assert_integer(CardMin), + assert_integer(CardMax), + gecode_new_setvar(Idx, Space_, GlbMin, GlbMax, LubMib, LubMax, CardMin, CardMax), + SVar='SetVar'(Idx). + +%% 5 arguments +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin) 5 new_setvar_2 +%% (Glb,LubMin,LubMax,CardMin,CardMax) 5 new_setvar_4 +%% (GlbMin,GlbMax,Lub,CardMin,CardMax) 5 new_setvar_7 +new_setvar(SVar, Space, X1, X2, X3, X4, X5) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + (integer(X1) + -> + assert_integer(X2), + assert_integer(X4), + assert_integer(X5), + (is_IntSet(X3,X3_) + -> gecode_new_setvar_7(Idx,Space_,X1,X2,X3_,X4,X5) + ; gecode_new_setvar_2(Idx,Space_,X1,X2,X3,X4,X5)) + ; + assert_is_IntSet(X1,X1_), + assert_integer(X2), + assert_integer(X3), + assert_integer(X4), + assert_integer(X5), + gecode_new_setvar_4(Idx,Space_,X1_,X2,X3,X4,X5)), + SVar='SetVar'(Idx). + +%% 4 arguments +%% (GlbMin,GlbMax,LubMin,LubMax) 4 new_setvar_3 +%% (Glb,LubMin,LubMax,CardMin) 4 new_setvar_5 +%% (GlbMin,GlbMax,Lub,CardMin) 4 new_setvar_8 +%% (Glb,Lub,CardMin,CardMax) 4 new_setvar_10 +new_setvar(SVar,Space,X1,X2,X3,X4) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(X4), + (is_IntSet(X1,X1_) + -> (is_IntSet(X2,X2_) + -> + assert_integer(X3), + gecode_new_setvar_10(Idx,Space_,X1_,X2_,X3,X4) + ; + assert_integer(X2), + assert_integer(X3), + gecode_new_setvar_5(Idx,Space_,X1_,X2,X3,X4)) + ; + assert_integer(X1), + assert_integer(X2), + (is_IntSet(X3,X3_) + -> + gecode_new_setvar_8(Idx,Space_,X1,X2,X3_,X4) + ; + assert_integer(X3), + gecode_new_setvar_3(Idx,Space_,X1,X2,X3,X4))), + SVar='SetVar'(Idx). + +%% 3 arguments +%% (Glb,LubMin,LubMax) 3 new_setvar_6 +%% (GlbMin,GlbMax,Lub) 3 new_setvar_9 +%% (Glb,Lub,CardMin) 3 new_setvar_11 +new_setvar(SVar,Space,X1,X2,X3) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + (is_IntSet(X1,X1_) + -> (is_IntSet(X2,X2_) + -> + assert_integer(X3), + gecode_new_setvar_11(Idx,Space_,X1_,X2_,X3) + ; + assert_integer(X2), + assert_integer(X3), + gecode_new_setvar_6(Idx,Space_,X1_,X2,X3)) + ; + assert_integer(X1), + assert_integer(X2), + assert_is_IntSet(X3,X3_), + gecode_new_setvar_9(Idx,Space_,X1,X2,X3_)), + SVar='SetVar'(Idx). + +%% 2 arguments +%% (Glb,Lub) 2 new_setvar_12 +new_setvar(SVar,Space,X1,X2) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_is_IntSet(X1,X1_), + assert_is_IntSet(X2,X2_), + gecode_new_setvar_12(Idx,Space_,X1_,X2_), + SVar='SetVar'(Idx). + +minimize(Space,IVar) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar,IVar_), + gecode_space_minimize(Space_,IVar_). +maximize(Space,IVar) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar,IVar_), + gecode_space_maximize(Space_,IVar_). +minimize(Space,IVar1,IVar2) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar1,IVar1_), + assert_is_IntVar(IVar2,IVar2_), + gecode_space_minimize_ratio(Space_,IVar1_,IVar2_). +maximize(Space,IVar1,IVar2) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar1,IVar1_), + assert_is_IntVar(IVar2,IVar2_), + gecode_space_maximize_ratio(Space_,IVar1_,IVar2_). + +search(Space, Solution) :- + assert_is_Space(Space,Space_), + assert_var(Solution), + gecode_new_engine(Space_,Engine_), + gecode_engine_search(Engine_,Solution_), + Solution='Space'(Solution_). + +%% INSPECTING VARIABLES + +get_for_vars([],Space,[],F). +get_for_vars([V|Vs],Space,[V2|V2s],F) :- + call_with_args(F,V,Space,V2), + get_for_vars(Vs,Space,V2s,F). + +get_assigned(Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_assigned(Space_,Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_assigned(Space_,Var_) + ; is_SetVar(Var,Var_) + -> gecode_setvar_assigned(Space_,Var_) + ; throw(gecode_error(expected(variable))). + +get_min(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_min(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_min(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_min). + +get_max(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_max(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_max(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_max). + +get_med(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_med(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_med(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_med). + +get_val(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_val(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_val(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_val). + +get_size(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_size(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_size(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_size). + +get_width(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_width(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_width(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_width). + +get_regret_min(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_regret_min(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_regret_min(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_regret_min). + +get_regret_max(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_IntVar(Var,Var_) + -> gecode_intvar_regret_max(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_regret_max(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_regret_max). + +get_glbSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_glbSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbSize). + +get_lubSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_lubSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubSize). + +get_unknownSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_unknownSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_unknownSize). + +get_cardMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_cardMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_cardMin). + +get_cardMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_cardMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_cardMax). + +get_lubMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_lubMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubMin). + +get_lubMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_lubMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubMax). + +get_glbMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_glbMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbMin). + +get_glbMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_glbMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbMax). + +get_glb_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_glb_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_glb_ranges). + +get_lub_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_lub_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_lub_ranges). + +get_unknown_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_unknown_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_unknown_ranges). + +get_glb_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_glb_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_glb_values). + +get_lub_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_lub_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_lub_values). + +get_unknown_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + is_SetVar(Var,Var_) + -> gecode_setvar_unknown_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_unknown_values). + +new_disjunctor(X, Space) :- + assert_is_Space(Space,Space_), + gecode_new_disjunctor(D,Space_), + X='Disjunctor'(D). + +is_Disjunctor_('Disjunctor'(D),D). +is_Disjunctor(X,Y) :- nonvar(X), is_Disjunctor_(X,Y). +is_Disjunctor(X) :- is_Disjunctor(X,_). + +assert_is_Disjunctor(X,Y) :- + is_Disjunctor(X,Y) -> true ; throw(gecode_error(expected(disjunctor))). + +new_clause(X, Disj) :- + assert_is_Disjunctor(Disj,Disj_), + gecode_new_clause(C, Disj_), + X='Clause'(C). + +is_Clause_('Clause'(C),C). +is_Clause(X,Y) :- nonvar(X), is_Clause_(X,Y). +is_Clause(X) :- is_Clause(X,_). + +assert_is_Clause(X,Y) :- + is_Clause(X,Y) -> true ; throw(gecode_error(expected(clause))). + +is_Space_or_Clause(X,Y) :- + (is_Space(X,Y);is_Clause(X,Y)), !. +assert_is_Space_or_Clause(X,Y) :- + is_Space_or_Clause(X,Y) -> true + ; throw(gecode_error(expected(space,clause))). + +new_forward(Clause, X, Y) :- + assert_is_Clause(Clause, Clause_), + (is_IntVar(X,X_) + -> (is_IntVar(Y,Y_) + -> gecode_clause_intvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (is_BoolVar(X,X_) + -> (is_BoolVar(Y,Y_) + -> gecode_clause_boolvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (is_SetVar(X,X_) + -> (is_SetVar(Y,Y_) + -> gecode_clause_setvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (X=[] + -> Y=[] + ;(X=[H1|T1],Y=[H2|T2]) + -> (new_forward(Clause,H1,H2), + new_forward(Clause,T1,T2)) + ; throw(gecode_error(forward)))))). + +new_intvars_(L,Space,N,I,J) :- length(L,N), new_intvars(L,Space,I,J). +new_intvars_(L,Space,N,IntSet) :- length(L,N), new_intvars(L,Space,IntSet). +new_boolvars_(L,Space,N) :- length(L,N), new_boolvars(L,Space). +new_setvars_(L,Space,N,X1,X2,X3,X4,X5,X6) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4,X5,X6). +new_setvars_(L,Space,N,X1,X2,X3,X4,X5) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4,X5). +new_setvars_(L,Space,N,X1,X2,X3,X4) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4). +new_setvars_(L,Space,N,X1,X2,X3) :- length(L,N), new_setvars(L,Space,X1,X2,X3). +new_setvars_(L,Space,N,X1,X2) :- length(L,N), new_setvars(L,Space,X1,X2). + +%% more concise interface: +(X := Y) :- var(Y), !, throw(gecode_error((X := Y))). +(X := intset(I,J)) :- !, new_intset(X,I,J). +(X := intset(L)) :- !, new_intset(X,L). +(X := space) :- !, new_space(X). +(X := intvar(Space,I,J)) :- !, new_intvar(X,Space,I,J). +(X := intvar(Space,IntSet)) :- !, new_intvar(X,Space,IntSet). +(X := boolvar(Space)) :- !, new_boolvar(X,Space). +(X := setvar(Space,X1,X2,X3,X4,X5,X6)) :- !, new_setvar(X,Space,X1,X2,X3,X4,X5,X6). +(X := setvar(Space,X1,X2,X3,X4,X5)) :- !, new_setvar(X,Space,X1,X2,X3,X4,X5). +(X := setvar(Space,X1,X2,X3,X4)) :- !, new_setvar(X,Space,X1,X2,X3,X4). +(X := setvar(Space,X1,X2,X3)) :- !, new_setvar(X,Space,X1,X2,X3). +(X := setvar(Space,X1,X2)) :- !, new_setvar(X,Space,X1,X2). +(X := intvars(Space,N,I,J)) :- !, new_intvars_(X,Space,N,I,J). +(X := intvars(Space,N,IntSet)) :- !, new_intvars_(X,Space,N,IntSet). +(X := boolvars(Space,N)) :- !, new_boolvars_(X,Space,N). +(X := setvars(Space,N,X1,X2,X3,X4,X5,X6)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4,X5,X6). +(X := setvars(Space,N,X1,X2,X3,X4,X5)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4,X5). +(X := setvars(Space,N,X1,X2,X3,X4)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4). +(X := setvars(Space,N,X1,X2,X3)) :- !, new_setvars_(X,Space,N,X1,X2,X3). +(X := setvars(Space,N,X1,X2)) :- !, new_setvars_(X,Space,N,X1,X2). + +(X := min(Space,Var)) :- !, get_min(X,Space,Var). +(X := max(Space,Var)) :- !, get_max(X,Space,Var). +(X := med(Space,Var)) :- !, get_med(X,Space,Var). +(X := val(Space,Var)) :- !, get_val(X,Space,Var). +(X := size(Space,Var)) :- !, get_size(X,Space,Var). +(X := width(Space,Var)) :- !, get_width(X,Space,Var). +(X := regret_min(Space,Var)) :- !, get_regret_min(X,Space,Var). +(X := regret_max(Space,Var)) :- !, get_regret_max(X,Space,Var). + +(X := glbSize(Space,Var)) :- !, get_glbSize(X,Space,Var). +(X := lubSize(Space,Var)) :- !, get_lubSize(X,Space,Var). +(X := unknownSize(Space,Var)) :- !, get_unknownSize(X,Space,Var). +(X := cardMin(Space,Var)) :- !, get_cardMin(X,Space,Var). +(X := cardMax(Space,Var)) :- !, get_cardMax(X,Space,Var). +(X := lubMin(Space,Var)) :- !, get_lubMin(X,Space,Var). +(X := lubMax(Space,Var)) :- !, get_lubMax(X,Space,Var). +(X := glbMin(Space,Var)) :- !, get_glbMin(X,Space,Var). +(X := glbMax(Space,Var)) :- !, get_glbMax(X,Space,Var). +(X := glb_ranges(Space,Var)) :- !, get_glb_ranges(X,Space,Var). +(X := lub_ranges(Space,Var)) :- !, get_lub_ranges(X,Space,Var). +(X := unknown_ranges(Space,Var)) :- !, get_unknown_ranges(X,Space,Var). +(X := glb_values(Space,Var)) :- !, get_glb_values(X,Space,Var). +(X := lub_values(Space,Var)) :- !, get_lub_values(X,Space,Var). +(X := unknown_values(Space,Var)) :- !, get_unknown_values(X,Space,Var). + +(X := disjunctor(Space)) :- !, new_disjunctor(X,Space). +(X := clause(Disj)) :- !, new_clause(X,Disj). + +(X := search(Y)) :- !, search(Y,X). + +% these should be autogenerated: +(C += forward(X,Y)) :- !, new_forward(C,X,Y). +(Space += abs(X1,X2)) :- !, abs(Space,X1,X2). +(Space += abs(X1,X2,X3)) :- !, abs(Space,X1,X2,X3). +(Space += assign(X1,X2)) :- !, assign(Space,X1,X2). +(Space += atmostOne(X1,X2)) :- !, atmostOne(Space,X1,X2). +(Space += binpacking(X1,X2,X3)) :- !, binpacking(Space,X1,X2,X3). +(Space += binpacking(X1,X2,X3,X4)) :- !, binpacking(Space,X1,X2,X3,X4). +(Space += branch(X1,X2)) :- !, branch(Space,X1,X2). +(Space += branch(X1,X2,X3)) :- !, branch(Space,X1,X2,X3). +(Space += cardinality(X1,X2)) :- !, cardinality(Space,X1,X2). +(Space += cardinality(X1,X2,X3)) :- !, cardinality(Space,X1,X2,X3). +(Space += channel(X1,X2)) :- !, channel(Space,X1,X2). +(Space += channel(X1,X2,X3)) :- !, channel(Space,X1,X2,X3). +(Space += channel(X1,X2,X3,X4)) :- !, channel(Space,X1,X2,X3,X4). +(Space += channel(X1,X2,X3,X4,X5)) :- !, channel(Space,X1,X2,X3,X4,X5). +(Space += channelSorted(X1,X2)) :- !, channelSorted(Space,X1,X2). +(Space += circuit(X1)) :- !, circuit(Space,X1). +(Space += circuit(X1,X2)) :- !, circuit(Space,X1,X2). +(Space += circuit(X1,X2,X3)) :- !, circuit(Space,X1,X2,X3). +(Space += circuit(X1,X2,X3,X4)) :- !, circuit(Space,X1,X2,X3,X4). +(Space += circuit(X1,X2,X3,X4,X5)) :- !, circuit(Space,X1,X2,X3,X4,X5). +(Space += circuit(X1,X2,X3,X4,X5,X6)) :- !, circuit(Space,X1,X2,X3,X4,X5,X6). +(Space += clause(X1,X2,X3,X4)) :- !, clause(Space,X1,X2,X3,X4). +(Space += clause(X1,X2,X3,X4,X5)) :- !, clause(Space,X1,X2,X3,X4,X5). +(Space += convex(X1)) :- !, convex(Space,X1). +(Space += convex(X1,X2)) :- !, convex(Space,X1,X2). +(Space += count(X1,X2)) :- !, count(Space,X1,X2). +(Space += count(X1,X2,X3)) :- !, count(Space,X1,X2,X3). +(Space += count(X1,X2,X3,X4)) :- !, count(Space,X1,X2,X3,X4). +(Space += count(X1,X2,X3,X4,X5)) :- !, count(Space,X1,X2,X3,X4,X5). +(Space += cumulative(X1,X2,X3,X4)) :- !, cumulative(Space,X1,X2,X3,X4). +(Space += cumulative(X1,X2,X3,X4,X5)) :- !, cumulative(Space,X1,X2,X3,X4,X5). +(Space += cumulative(X1,X2,X3,X4,X5,X6)) :- !, cumulative(Space,X1,X2,X3,X4,X5,X6). +(Space += cumulative(X1,X2,X3,X4,X5,X6,X7)) :- !, cumulative(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += cumulatives(X1,X2,X3,X4,X5,X6,X7)) :- !, cumulatives(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += cumulatives(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, cumulatives(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += distinct(X1)) :- !, distinct(Space,X1). +(Space += distinct(X1,X2)) :- !, distinct(Space,X1,X2). +(Space += distinct(X1,X2,X3)) :- !, distinct(Space,X1,X2,X3). +(Space += div(X1,X2,X3)) :- !, div(Space,X1,X2,X3). +(Space += div(X1,X2,X3,X4)) :- !, div(Space,X1,X2,X3,X4). +(Space += divmod(X1,X2,X3,X4)) :- !, divmod(Space,X1,X2,X3,X4). +(Space += divmod(X1,X2,X3,X4,X5)) :- !, divmod(Space,X1,X2,X3,X4,X5). +(Space += dom(X1,X2)) :- !, dom(Space,X1,X2). +(Space += dom(X1,X2,X3)) :- !, dom(Space,X1,X2,X3). +(Space += dom(X1,X2,X3,X4)) :- !, dom(Space,X1,X2,X3,X4). +(Space += dom(X1,X2,X3,X4,X5)) :- !, dom(Space,X1,X2,X3,X4,X5). +(Space += element(X1,X2,X3)) :- !, element(Space,X1,X2,X3). +(Space += element(X1,X2,X3,X4)) :- !, element(Space,X1,X2,X3,X4). +(Space += element(X1,X2,X3,X4,X5)) :- !, element(Space,X1,X2,X3,X4,X5). +(Space += element(X1,X2,X3,X4,X5,X6)) :- !, element(Space,X1,X2,X3,X4,X5,X6). +(Space += element(X1,X2,X3,X4,X5,X6,X7)) :- !, element(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += linear(X1,X2,X3)) :- !, linear(Space,X1,X2,X3). +(Space += linear(X1,X2,X3,X4)) :- !, linear(Space,X1,X2,X3,X4). +(Space += linear(X1,X2,X3,X4,X5)) :- !, linear(Space,X1,X2,X3,X4,X5). +(Space += linear(X1,X2,X3,X4,X5,X6)) :- !, linear(Space,X1,X2,X3,X4,X5,X6). +(Space += max(X1,X2)) :- !, max(Space,X1,X2). +(Space += max(X1,X2,X3)) :- !, max(Space,X1,X2,X3). +(Space += max(X1,X2,X3,X4)) :- !, max(Space,X1,X2,X3,X4). +(Space += min(X1,X2)) :- !, min(Space,X1,X2). +(Space += min(X1,X2,X3)) :- !, min(Space,X1,X2,X3). +(Space += min(X1,X2,X3,X4)) :- !, min(Space,X1,X2,X3,X4). +(Space += mod(X1,X2,X3)) :- !, mod(Space,X1,X2,X3). +(Space += mod(X1,X2,X3,X4)) :- !, mod(Space,X1,X2,X3,X4). +(Space += mult(X1,X2,X3)) :- !, mult(Space,X1,X2,X3). +(Space += mult(X1,X2,X3,X4)) :- !, mult(Space,X1,X2,X3,X4). +(Space += nooverlap(X1,X2,X3,X4)) :- !, nooverlap(Space,X1,X2,X3,X4). +(Space += nooverlap(X1,X2,X3,X4,X5)) :- !, nooverlap(Space,X1,X2,X3,X4,X5). +(Space += nooverlap(X1,X2,X3,X4,X5,X6)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6). +(Space += nooverlap(X1,X2,X3,X4,X5,X6,X7)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += nooverlap(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += notMax(X1,X2)) :- !, notMax(Space,X1,X2). +(Space += notMin(X1,X2)) :- !, notMin(Space,X1,X2). +(Space += path(X1,X2,X3)) :- !, path(Space,X1,X2,X3). +(Space += path(X1,X2,X3,X4)) :- !, path(Space,X1,X2,X3,X4). +(Space += path(X1,X2,X3,X4,X5)) :- !, path(Space,X1,X2,X3,X4,X5). +(Space += path(X1,X2,X3,X4,X5,X6)) :- !, path(Space,X1,X2,X3,X4,X5,X6). +(Space += path(X1,X2,X3,X4,X5,X6,X7)) :- !, path(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += path(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, path(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += precede(X1,X2)) :- !, precede(Space,X1,X2). +(Space += precede(X1,X2,X3)) :- !, precede(Space,X1,X2,X3). +(Space += precede(X1,X2,X3,X4)) :- !, precede(Space,X1,X2,X3,X4). +(Space += rel(X1,X2)) :- !, rel(Space,X1,X2). +(Space += rel(X1,X2,X3)) :- !, rel(Space,X1,X2,X3). +(Space += rel(X1,X2,X3,X4)) :- !, rel(Space,X1,X2,X3,X4). +(Space += rel(X1,X2,X3,X4,X5)) :- !, rel(Space,X1,X2,X3,X4,X5). +(Space += sequence(X1)) :- !, sequence(Space,X1). +(Space += sequence(X1,X2)) :- !, sequence(Space,X1,X2). +(Space += sequence(X1,X2,X3,X4,X5)) :- !, sequence(Space,X1,X2,X3,X4,X5). +(Space += sequence(X1,X2,X3,X4,X5,X6)) :- !, sequence(Space,X1,X2,X3,X4,X5,X6). +(Space += sorted(X1,X2)) :- !, sorted(Space,X1,X2). +(Space += sorted(X1,X2,X3)) :- !, sorted(Space,X1,X2,X3). +(Space += sorted(X1,X2,X3,X4)) :- !, sorted(Space,X1,X2,X3,X4). +(Space += sqr(X0,X1,X2,X3)) :- !, sqr(Space,X0,X1,X2,X3). +(Space += sqr(X1,X2)) :- !, sqr(Space,X1,X2). +(Space += sqrt(X1,X2)) :- !, sqrt(Space,X1,X2). +(Space += sqrt(X1,X2,X3)) :- !, sqrt(Space,X1,X2,X3). +(Space += unary(X1,X2)) :- !, unary(Space,X1,X2). +(Space += unary(X1,X2,X3)) :- !, unary(Space,X1,X2,X3). +(Space += unary(X1,X2,X3,X4)) :- !, unary(Space,X1,X2,X3,X4). +(Space += unary(X1,X2,X3,X4,X5)) :- !, unary(Space,X1,X2,X3,X4,X5). +(Space += unshare(X1)) :- !, unshare(Space,X1). +(Space += unshare(X1,X2)) :- !, unshare(Space,X1,X2). +(Space += weights(X1,X2,X3,X4)) :- !; weights(Space,X1,X2,X3,X4). + +(Space += minimize(X)) :- !, minimize(Space,X). +(Space += maximize(X)) :- !, maximize(Space,X). +(Space += minimize(X,Y)) :- !, minimize(Space,X,Y). +(Space += maximize(X,Y)) :- !, maximize(Space,X,Y). diff --git a/library/gecode/send_more_money.yap b/library/gecode/send_more_money.yap new file mode 100644 index 000000000..7df9db5a9 --- /dev/null +++ b/library/gecode/send_more_money.yap @@ -0,0 +1,41 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +:- use_module(gecode). + +% S E N D +% + M O R E +% --------- +% M O N E Y +send_more_money(Solution) :- + Space := space, + Letters := intvars(Space,8,0,9), + [S,E,N,D,M,O,R,Y] = Letters, + Space += rel(M,'IRT_NQ',0), + Space += rel(S,'IRT_NQ',0), + Space += distinct(Letters), + C = [1000, 100, 10, 1, + 1000, 100, 10, 1, + -10000, -1000, -100, -10, -1], + X = [S,E,N,D, + M,O,R,E, + M,O,N,E,Y], + Space += linear(C, X, 'IRT_EQ', 0), + Space += branch(Letters, 'INT_VAR_SIZE_MIN', 'INT_VAL_MIN'), + SolSpace := search(Space), + Solution := val(SolSpace,Letters). diff --git a/library/gecode/send_most_money.yap b/library/gecode/send_most_money.yap new file mode 100644 index 000000000..7dae5afc9 --- /dev/null +++ b/library/gecode/send_most_money.yap @@ -0,0 +1,45 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 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 Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +:- use_module(gecode). + +% S E N D +% + M O S T +% --------- +% M O N E Y +send_most_money(Solution,Amount) :- + Space := space, + Letters := intvars(Space,8,0,9), + [S,E,N,D,M,O,T,Y] = Letters, + Space += rel(M,'IRT_NQ',0), + Space += rel(S,'IRT_NQ',0), + Space += distinct(Letters), + C = [1000, 100, 10, 1, + 1000, 100, 10, 1, + -10000, -1000, -100, -10, -1], + X = [S,E,N,D, + M,O,S,T, + M,O,N,E,Y], + Space += linear(C, X, 'IRT_EQ', 0), + Money := intvar(Space,0,99999), + Space += linear([10000,1000,100,10,1],[M,O,N,E,Y],'IRT_EQ',Money), + Space += maximize(Money), + Space += branch(Letters,'INT_VAR_SIZE_MIN','INT_VAL_MIN'), + SolSpace := search(Space), + Solution := val(SolSpace,Letters), + Amount := val(SolSpace,Money).