From 601bc81464f7a5cef7ce4a03a0ba396f0a895d0a Mon Sep 17 00:00:00 2001 From: RIGUZZI FABRIZIO - Dipartimento di Ingegneria Date: Thu, 18 Mar 2010 15:16:28 +0100 Subject: [PATCH 1/6] fixed cplint new dir --- Makefile.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index 45cc20211..6a6dd0f14 100755 --- a/Makefile.in +++ b/Makefile.in @@ -487,7 +487,7 @@ all: startup.yss @USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE)) @INSTALL_MATLAB@ (cd library/matlab; $(MAKE)) @ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE)) - @ENABLE_CPLINT@ (cd cplint; $(MAKE)) + @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE)) @USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE)) startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES) @@ -540,7 +540,7 @@ install_unix: startup.yss libYap.a for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done $(INSTALL) config.h $(DESTDIR)$(INCLUDEDIR)/config.h $(INSTALL) parms.h $(DESTDIR)$(INCLUDEDIR)/parms.h - @ENABLE_CPLINT@ (cd cplint; $(MAKE) install) + @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install) @USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install) @@ -578,7 +578,7 @@ install_win32: startup.yss @ENABLE_WINCONSOLE@ (cd LGPL/swi_console; $(MAKE) install) @INSTALL_MATLAB@ (cd library/matlab; $(MAKE) install) (cd library/tries; $(MAKE) install) - @ENABLE_CPLINT@ (cd cplint; $(MAKE) install) + @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install) @USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install) install_library: @YAPLIB@ @@ -715,7 +715,8 @@ realclean_docs: clean_docs rm -f yap.ps yap.html yap_toc.html yap.pdf yap.info* installcheck: - @ENABLE_CPLINT@ (cd cplint; $(MAKE) installcheck) + @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) installcheck) + # DO NOT DELETE THIS LINE -- make depend depends on it. From db2eefd0c9207d5390d411fefb1d2d0884c1d943 Mon Sep 17 00:00:00 2001 From: RIGUZZI FABRIZIO - Dipartimento di Ingegneria Date: Thu, 18 Mar 2010 16:11:21 +0100 Subject: [PATCH 2/6] added approximated cplint --- Makefile.in | 1 + configure | 13491 +++++++++++++--- configure.in | 6 +- packages/cplint/Makefile.in | 28 +- packages/cplint/approx/.svn/all-wcprops | 77 + packages/cplint/approx/.svn/entries | 446 + packages/cplint/approx/.svn/format | 1 + .../.svn/text-base/INSTALL.txt.svn-base | 5 + .../.svn/text-base/bestfirst.pl.svn-base | 451 + .../approx/.svn/text-base/bestk.pl.svn-base | 528 + .../approx/.svn/text-base/deepdyn.pl.svn-base | 352 + .../approx/.svn/text-base/deepit.pl.svn-base | 352 + .../approx/.svn/text-base/exact.pl.svn-base | 235 + .../.svn/text-base/exact_mem.pl.svn-base | 189 + .../.svn/text-base/montecarlo.pl.svn-base | 275 + .../approx/.svn/text-base/params.pl.svn-base | 122 + .../approx/.svn/text-base/parsing.pl.svn-base | 344 + .../.svn/text-base/tptreefile.pl.svn-base | 727 + .../approx/.svn/text-base/utility.pl.svn-base | 367 + packages/cplint/approx/bestfirst.pl | 451 + packages/cplint/approx/bestk.pl | 528 + packages/cplint/approx/deepdyn.pl | 352 + packages/cplint/approx/deepit.pl | 352 + packages/cplint/approx/exact.pl | 235 + packages/cplint/approx/exact_mem.pl | 189 + packages/cplint/approx/montecarlo.pl | 275 + packages/cplint/approx/params.pl | 122 + packages/cplint/approx/parsing.pl | 344 + .../approx/simplecuddLPADs/.svn/all-wcprops | 47 + .../approx/simplecuddLPADs/.svn/entries | 273 + .../cplint/approx/simplecuddLPADs/.svn/format | 1 + .../.svn/text-base/Makefile.svn-base | 55 + .../.svn/text-base/ProblogBDD.c.svn-base | 871 + .../.svn/text-base/ProblogBDDclus.c.svn-base | 895 + .../.svn/text-base/general.c.svn-base | 234 + .../.svn/text-base/general.h.svn-base | 159 + .../.svn/text-base/simplecudd.c.svn-base | 1747 ++ .../.svn/text-base/simplecudd.h.svn-base | 306 + .../cplint/approx/simplecuddLPADs/Makefile.in | 54 + .../approx/simplecuddLPADs/ProblogBDD.c | 871 + .../approx/simplecuddLPADs/ProblogBDDclus.c | 895 + .../cplint/approx/simplecuddLPADs/general.c | 234 + .../cplint/approx/simplecuddLPADs/general.h | 159 + .../approx/simplecuddLPADs/simplecudd.c | 1747 ++ .../approx/simplecuddLPADs/simplecudd.h | 306 + packages/cplint/approx/tptreefile.pl | 727 + packages/cplint/approx/utility.pl | 367 + packages/cplint/cplint_yap.c | 2 +- packages/cplint/lpadsld.pl | 20 +- packages/cplint/slg.pl | 4 +- packages/cplint/testcpl.pl | 1 + packages/cplint/testlpadvel.pl | 4 +- packages/cplint/testsemlpad.pl | 2 +- packages/cplint/testsemlpadsld.pl | 8 +- 54 files changed, 28413 insertions(+), 2421 deletions(-) create mode 100644 packages/cplint/approx/.svn/all-wcprops create mode 100644 packages/cplint/approx/.svn/entries create mode 100644 packages/cplint/approx/.svn/format create mode 100644 packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/bestk.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/deepit.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/exact.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/params.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/parsing.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base create mode 100644 packages/cplint/approx/.svn/text-base/utility.pl.svn-base create mode 100644 packages/cplint/approx/bestfirst.pl create mode 100644 packages/cplint/approx/bestk.pl create mode 100644 packages/cplint/approx/deepdyn.pl create mode 100644 packages/cplint/approx/deepit.pl create mode 100644 packages/cplint/approx/exact.pl create mode 100644 packages/cplint/approx/exact_mem.pl create mode 100644 packages/cplint/approx/montecarlo.pl create mode 100644 packages/cplint/approx/params.pl create mode 100644 packages/cplint/approx/parsing.pl create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/entries create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/format create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.c.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base create mode 100644 packages/cplint/approx/simplecuddLPADs/Makefile.in create mode 100644 packages/cplint/approx/simplecuddLPADs/ProblogBDD.c create mode 100644 packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c create mode 100644 packages/cplint/approx/simplecuddLPADs/general.c create mode 100644 packages/cplint/approx/simplecuddLPADs/general.h create mode 100644 packages/cplint/approx/simplecuddLPADs/simplecudd.c create mode 100644 packages/cplint/approx/simplecuddLPADs/simplecudd.h create mode 100644 packages/cplint/approx/tptreefile.pl create mode 100644 packages/cplint/approx/utility.pl diff --git a/Makefile.in b/Makefile.in index 6a6dd0f14..ea0b0045c 100755 --- a/Makefile.in +++ b/Makefile.in @@ -487,6 +487,7 @@ all: startup.yss @USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE)) @INSTALL_MATLAB@ (cd library/matlab; $(MAKE)) @ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE)) + @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE)) @ENABLE_CPLINT@ (cd packages/cplint; $(MAKE)) @USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE)) diff --git a/configure b/configure index 0273a7208..51b30272e 100755 --- a/configure +++ b/configure @@ -1,22 +1,18 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65. -# +# Generated by GNU Autoconf 2.63. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# -# +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -24,15 +20,23 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; esac + fi + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + as_nl=' ' export as_nl @@ -40,13 +44,7 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -57,7 +55,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in #( + case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -80,6 +78,13 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -89,15 +94,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( +case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done IFS=$as_save_IFS ;; @@ -109,16 +114,12 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 + { (exit 1); exit 1; } fi -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' @@ -130,248 +131,7 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - +# Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -385,12 +145,8 @@ else as_basename=false fi -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -410,19 +166,295 @@ $as_echo X/"$0" | } s/.*/./; q'` -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits +# CDPATH. +$as_unset CDPATH - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= @@ -439,7 +471,8 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the @@ -449,18 +482,29 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits exit } + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( +case `echo -n x` in -n*) - case `echo 'xy\c'` in + case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; + *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -490,7 +534,7 @@ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' + as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -509,10 +553,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in #( + case $1 in -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -526,8 +570,8 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -test -n "$DJDIR" || exec 7<&0 &1 + +exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, @@ -545,6 +589,7 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME= @@ -552,7 +597,6 @@ PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= -PACKAGE_URL= ac_unique_file="console/yap.c" # Factoring default headers for most tests. @@ -723,7 +767,6 @@ bindir program_transform_name prefix exec_prefix -PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -895,7 +938,8 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -921,7 +965,8 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1125,7 +1170,8 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1141,7 +1187,8 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1171,17 +1218,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; - esac + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1198,13 +1245,15 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1227,7 +1276,8 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -1257,9 +1307,11 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + { $as_echo "$as_me: error: working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } # Find the source files, if location was not specified. @@ -1298,11 +1350,13 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1451,7 +1505,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags @@ -1460,7 +1514,6 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to the package provider. _ACEOF ac_status=$? fi @@ -1524,588 +1577,21 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.65 +generated by GNU Autoconf 2.63 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -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_compile") 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_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -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_compile") 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_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # 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; test "x$as_lineno_stack" = x && { as_lineno=; 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. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -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_cpp conftest.$ac_ext") 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; } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - 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>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { 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_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_compile - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_func - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.63. Invocation command line was $ $0 $@ @@ -2141,8 +1627,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done + $as_echo "PATH: $as_dir" +done IFS=$as_save_IFS } >&5 @@ -2179,9 +1665,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) - as_fn_append ac_configure_args1 " '$ac_arg'" + ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -2197,13 +1683,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - as_fn_append ac_configure_args " '$ac_arg'" + ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -2228,13 +1714,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; + *) $as_unset $ac_var ;; esac ;; esac done @@ -2306,39 +1792,37 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h -$as_echo "/* confdefs.h */" > confdefs.h - # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF + cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF + cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF + cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF @@ -2358,8 +1842,8 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 + if test -r "$ac_site_file"; then + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" @@ -2367,10 +1851,10 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -2378,7 +1862,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -2393,11 +1877,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -2407,17 +1891,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -2429,20 +1913,35 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## + + + + + + + + + + + + + + + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -2464,9 +1963,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2477,24 +1976,24 @@ 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 + 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_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 + { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2504,9 +2003,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2517,24 +2016,24 @@ 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 + 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_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2543,7 +2042,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2557,9 +2056,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2570,24 +2069,24 @@ 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 + 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_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 + { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2597,9 +2096,9 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2611,18 +2110,18 @@ 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 + 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 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -2641,10 +2140,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 + { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2656,9 +2155,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2669,24 +2168,24 @@ 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 + 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_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 + { $as_echo "$as_me:$LINENO: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2700,9 +2199,9 @@ if test -z "$CC"; then 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 "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2713,24 +2212,24 @@ 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 + 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_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -2743,7 +2242,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2754,37 +2253,57 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } # Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" +{ (ac_try="$ac_compiler --version >&5" 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_compiler $ac_option >&5") 2>conftest.err +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -2800,8 +2319,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } +{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2817,17 +2336,17 @@ do done rm -f $ac_rmfiles -if { { ac_try="$ac_link_default" +if { (ac_try="$ac_link_default" 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_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -2844,7 +2363,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -2863,42 +2382,84 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 + +{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } + ac_exeext=$ac_cv_exeext +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + fi + fi +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" +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_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -2913,83 +2474,32 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 + +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { 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>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { 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_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - 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 "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if test "${ac_cv_objext+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3001,17 +2511,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" +if { (ac_try="$ac_compile" 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_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -3024,23 +2534,31 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } fi + rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3054,16 +2572,37 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else - ac_compiler_gnu=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -3072,16 +2611,20 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if test "${ac_cv_prog_cc_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3092,11 +2635,35 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3107,12 +2674,36 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : else - ac_c_werror_flag=$ac_save_c_werror_flag + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3123,17 +2714,42 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -3150,14 +2766,18 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -3214,9 +2834,32 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi + rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -3227,19 +2870,17 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 + { $as_echo "$as_me:$LINENO: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 + { $as_echo "$as_me:$LINENO: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac -if test "x$ac_cv_prog_cc_c89" != xno; then : -fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3261,9 +2902,9 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : +if test "${ac_cv_prog_CXX+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -3274,24 +2915,24 @@ 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 + 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_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 + { $as_echo "$as_me:$LINENO: result: $CXX" >&5 $as_echo "$CXX" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -3305,9 +2946,9 @@ if test -z "$CXX"; then 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 "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -3318,24 +2959,24 @@ 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 + 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_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -3348,7 +2989,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -3359,36 +3000,53 @@ fi fi fi # Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" +{ (ac_try="$ac_compiler --version >&5" 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_compiler $ac_option >&5") 2>conftest.err +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3402,16 +3060,37 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else - ac_compiler_gnu=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes @@ -3420,16 +3099,20 @@ else fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : +if test "${ac_cv_prog_cxx_g+set}" = set; then $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3440,11 +3123,35 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3455,12 +3162,36 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -3471,17 +3202,42 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS @@ -3508,9 +3264,9 @@ for ac_prog in gawk mawk nawk awk 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 "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if test "${ac_cv_prog_AWK+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -3521,24 +3277,24 @@ 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 + 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_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 + { $as_echo "$as_me:$LINENO: result: $AWK" >&5 $as_echo "$AWK" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -3551,133 +3307,133 @@ done # Check whether --enable-tabling was given. -if test "${enable_tabling+set}" = set; then : +if test "${enable_tabling+set}" = set; then enableval=$enable_tabling; tabling="$enableval" else tabling=no fi # Check whether --enable-or-parallelism was given. -if test "${enable_or_parallelism+set}" = set; then : +if test "${enable_or_parallelism+set}" = set; then enableval=$enable_or_parallelism; orparallelism="$enableval" else orparallelism=no fi # Check whether --enable-rational-trees was given. -if test "${enable_rational_trees+set}" = set; then : +if test "${enable_rational_trees+set}" = set; then enableval=$enable_rational_trees; rationaltrees="$enableval" else rationaltrees=yes fi # Check whether --enable-coroutining was given. -if test "${enable_coroutining+set}" = set; then : +if test "${enable_coroutining+set}" = set; then enableval=$enable_coroutining; rationaltrees="$enableval";coroutining="$enableval" else coroutining=yes fi # Check whether --enable-depth-limit was given. -if test "${enable_depth_limit+set}" = set; then : +if test "${enable_depth_limit+set}" = set; then enableval=$enable_depth_limit; depthlimit="$enableval" else depthlimit=yes fi # Check whether --enable-wam-profile was given. -if test "${enable_wam_profile+set}" = set; then : +if test "${enable_wam_profile+set}" = set; then enableval=$enable_wam_profile; wamprofile="$enableval" else wamprofile=no fi # Check whether --enable-low-level-tracer was given. -if test "${enable_low_level_tracer+set}" = set; then : +if test "${enable_low_level_tracer+set}" = set; then enableval=$enable_low_level_tracer; lowleveltracer="$enableval" else lowleveltracer=no fi # Check whether --enable-threads was given. -if test "${enable_threads+set}" = set; then : +if test "${enable_threads+set}" = set; then enableval=$enable_threads; threads="$enableval" else threads=no fi # Check whether --enable-pthread-locking was given. -if test "${enable_pthread_locking+set}" = set; then : +if test "${enable_pthread_locking+set}" = set; then enableval=$enable_pthread_locking; pthreadlocking="$enableval" else pthreadlocking=no fi # Check whether --enable-max-performance was given. -if test "${enable_max_performance+set}" = set; then : +if test "${enable_max_performance+set}" = set; then enableval=$enable_max_performance; maxperformance="$enableval" else maxperformance=no fi # Check whether --enable-max-memory was given. -if test "${enable_max_memory+set}" = set; then : +if test "${enable_max_memory+set}" = set; then enableval=$enable_max_memory; maxmemory="$enableval" else maxmemory=yes fi # Check whether --enable-debug-yap was given. -if test "${enable_debug_yap+set}" = set; then : +if test "${enable_debug_yap+set}" = set; then enableval=$enable_debug_yap; debugyap="$enableval" else debugyap=no fi # Check whether --enable-eam was given. -if test "${enable_eam+set}" = set; then : +if test "${enable_eam+set}" = set; then enableval=$enable_eam; eam="$enableval" else eam=no fi # Check whether --enable-cygwin was given. -if test "${enable_cygwin+set}" = set; then : +if test "${enable_cygwin+set}" = set; then enableval=$enable_cygwin; cygwin="$enableval" else cygwin=no fi # Check whether --enable-dynamic_loading was given. -if test "${enable_dynamic_loading+set}" = set; then : +if test "${enable_dynamic_loading+set}" = set; then enableval=$enable_dynamic_loading; dynamic_loading="$enableval" else dynamic_loading=no fi # Check whether --enable-use-malloc was given. -if test "${enable_use_malloc+set}" = set; then : +if test "${enable_use_malloc+set}" = set; then enableval=$enable_use_malloc; use_malloc="$enableval" else use_malloc=no fi # Check whether --enable-condor was given. -if test "${enable_condor+set}" = set; then : +if test "${enable_condor+set}" = set; then enableval=$enable_condor; use_condor="$enableval" else use_condor=no fi # Check whether --enable-chr was given. -if test "${enable_chr+set}" = set; then : +if test "${enable_chr+set}" = set; then enableval=$enable_chr; use_chr="$enableval" else use_chr=yes fi # Check whether --enable-clpqr was given. -if test "${enable_clpqr+set}" = set; then : +if test "${enable_clpqr+set}" = set; then enableval=$enable_clpqr; use_clpqr="$enableval" else use_clpqr=yes @@ -3685,7 +3441,7 @@ fi # Check whether --enable-april was given. -if test "${enable_april+set}" = set; then : +if test "${enable_april+set}" = set; then enableval=$enable_april; use_april="$enableval" else use_april=no @@ -3693,7 +3449,7 @@ fi # Check whether --enable-dlcompat was given. -if test "${enable_dlcompat+set}" = set; then : +if test "${enable_dlcompat+set}" = set; then enableval=$enable_dlcompat; use_dlcompat="$enableval" else use_dlcompat=no @@ -3701,7 +3457,7 @@ fi # Check whether --enable-cplint was given. -if test "${enable_cplint+set}" = set; then : +if test "${enable_cplint+set}" = set; then enableval=$enable_cplint; yap_cv_cplint=$enableval else yap_cv_cplint=no @@ -3710,7 +3466,7 @@ fi # Check whether --with-gmp was given. -if test "${with_gmp+set}" = set; then : +if test "${with_gmp+set}" = set; then withval=$with_gmp; if test "$withval" = yes; then yap_cv_gmp=yes elif test "$withval" = no; then @@ -3727,7 +3483,7 @@ fi # Check whether --with-minisat was given. -if test "${with_minisat+set}" = set; then : +if test "${with_minisat+set}" = set; then withval=$with_minisat; if test "$withval" = yes; then yap_cv_minisat=yes elif test "$withval" = no; then @@ -3742,7 +3498,7 @@ fi # Check whether --with-cudd was given. -if test "${with_cudd+set}" = set; then : +if test "${with_cudd+set}" = set; then withval=$with_cudd; if test "$withval" = yes; then yap_cv_cudd=yes elif test "$withval" = no; then @@ -3758,7 +3514,7 @@ fi # Check whether --enable-myddas was given. -if test "${enable_myddas+set}" = set; then : +if test "${enable_myddas+set}" = set; then enableval=$enable_myddas; if test "$enableval" = yes; then yap_cv_myddas=/usr/ elif test "$enableval" = no; then @@ -3774,7 +3530,7 @@ fi # Check whether --enable-myddas-stats was given. -if test "${enable_myddas_stats+set}" = set; then : +if test "${enable_myddas_stats+set}" = set; then enableval=$enable_myddas_stats; if test "$yap_cv_myddas" = no; then myddasstats=no else @@ -3786,7 +3542,7 @@ fi # Check whether --enable-myddas-top-level was given. -if test "${enable_myddas_top_level+set}" = set; then : +if test "${enable_myddas_top_level+set}" = set; then enableval=$enable_myddas_top_level; if test "$yap_cv_myddas" = no; then myddastoplevel=no else @@ -3799,7 +3555,7 @@ fi # Check whether --with-jpl was given. -if test "${with_jpl+set}" = set; then : +if test "${with_jpl+set}" = set; then withval=$with_jpl; if test "$withval" = yes; then yap_cv_jpl="$JAVA_HOME" dynamic_loading=yes @@ -3818,7 +3574,7 @@ fi # Check whether --with-readline was given. -if test "${with_readline+set}" = set; then : +if test "${with_readline+set}" = set; then withval=$with_readline; if test "$withval" = yes; then yap_cv_readline=yes elif test "$withval" = no; then @@ -3835,7 +3591,7 @@ fi # Check whether --with-matlab was given. -if test "${with_matlab+set}" = set; then : +if test "${with_matlab+set}" = set; then withval=$with_matlab; if test "$withval" = yes; then yap_cv_matlab=yes elif test "$withval" = no; then @@ -3851,7 +3607,7 @@ fi # Check whether --with-mpi was given. -if test "${with_mpi+set}" = set; then : +if test "${with_mpi+set}" = set; then withval=$with_mpi; if test "$withval" = yes; then yap_cv_mpi=yes elif test "$withval" = no; then @@ -3869,7 +3625,7 @@ fi # Check whether --with-mpe was given. -if test "${with_mpe+set}" = set; then : +if test "${with_mpe+set}" = set; then withval=$with_mpe; if test "$withval" = yes; then yap_cv_mpe=yes elif test "$withval" = no; then @@ -3886,7 +3642,7 @@ fi # Check whether --with-lam was given. -if test "${with_lam+set}" = set; then : +if test "${with_lam+set}" = set; then withval=$with_lam; if test "$withval" = yes; then yap_cv_lam=yes elif test "$withval" = no; then @@ -3903,7 +3659,7 @@ fi # Check whether --with-heap-space was given. -if test "${with_heap_space+set}" = set; then : +if test "${with_heap_space+set}" = set; then withval=$with_heap_space; if test "$withval" = yes; then yap_cv_heap_space=0 elif test "$withval" = no; then @@ -3918,7 +3674,7 @@ fi # Check whether --with-stack-space was given. -if test "${with_stack_space+set}" = set; then : +if test "${with_stack_space+set}" = set; then withval=$with_stack_space; if test "$withval" = yes; then yap_cv_stack_space=0 elif test "$withval" = no; then @@ -3933,7 +3689,7 @@ fi # Check whether --with-trail-space was given. -if test "${with_trail_space+set}" = set; then : +if test "${with_trail_space+set}" = set; then withval=$with_trail_space; if test "$withval" = yes; then yap_cv_trail_space=0 elif test "$withval" = no; then @@ -3948,7 +3704,7 @@ fi # Check whether --with-max-workers was given. -if test "${with_max_workers+set}" = set; then : +if test "${with_max_workers+set}" = set; then withval=$with_max_workers; if test "$withval" = yes; then yap_cv_max_workers="(8*SIZEOF_INT_P)" elif test "$withval" = no; then @@ -3963,7 +3719,7 @@ fi # Check whether --with-max-threads was given. -if test "${with_max_threads+set}" = set; then : +if test "${with_max_threads+set}" = set; then withval=$with_max_threads; if test "$withval" = yes; then yap_cv_max_threads="1024" elif test "$withval" = no; then @@ -3978,7 +3734,7 @@ fi # Check whether --with-junit was given. -if test "${with_junit+set}" = set; then : +if test "${with_junit+set}" = set; then withval=$with_junit; case "$withval" in yes) JUNIT=/usr/share/java/junit.jar ;; @@ -3992,18 +3748,30 @@ fi if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes then - $as_echo "#define MinHeapSpace (1000*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinHeapSpace (1000*SIZEOF_INT_P) +_ACEOF - $as_echo "#define MinStackSpace (300*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinStackSpace (300*SIZEOF_INT_P) +_ACEOF - $as_echo "#define MinTrailSpace ( 48*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinTrailSpace ( 48*SIZEOF_INT_P) +_ACEOF else - $as_echo "#define MinHeapSpace (300*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinHeapSpace (300*SIZEOF_INT_P) +_ACEOF - $as_echo "#define MinStackSpace (200*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinStackSpace (200*SIZEOF_INT_P) +_ACEOF - $as_echo "#define MinTrailSpace ( 32*SIZEOF_INT_P)" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MinTrailSpace ( 32*SIZEOF_INT_P) +_ACEOF fi @@ -4026,16 +3794,24 @@ _ACEOF ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, @@ -4049,27 +3825,35 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +{ $as_echo "$as_me:$LINENO: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if test "${ac_cv_build+set}" = set; then $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +$as_echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -4085,24 +3869,28 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +{ $as_echo "$as_me:$LINENO: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if test "${ac_cv_host+set}" = set; then $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +$as_echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -4118,24 +3906,28 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +{ $as_echo "$as_me:$LINENO: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if test "${ac_cv_target+set}" = set; then : +if test "${ac_cv_target+set}" = set; then $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { (exit 1); exit 1; }; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +$as_echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -4158,7 +3950,6 @@ test -n "$target_alias" && NONENONEs,x,x, && program_prefix=${target_alias}- - cat >>confdefs.h <<_ACEOF #define HOST_ALIAS "${target}" _ACEOF @@ -4166,7 +3957,9 @@ _ACEOF if test "$or-parallelism" = no then - $as_echo "#define MAX_WORKERS 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MAX_WORKERS 1 +_ACEOF else cat >>confdefs.h <<_ACEOF @@ -4177,7 +3970,9 @@ fi if test "$threads" = no then - $as_echo "#define MAX_THREADS 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MAX_THREADS 1 +_ACEOF else cat >>confdefs.h <<_ACEOF @@ -4230,7 +4025,9 @@ then use_malloc="yes" CC="condor_compile $CC" yap_cv_readline="no" - $as_echo "#define SUPPORT_CONDOR 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define SUPPORT_CONDOR 1 +_ACEOF STATIC_MODE="" else @@ -4337,14 +4134,14 @@ else C_PARSER_FLAGS="$CFLAGS" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 + { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi @@ -4362,10 +4159,10 @@ fi # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if test "${ac_cv_path_install+set}" = set; then $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4373,11 +4170,11 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -4414,7 +4211,7 @@ case $as_dir/ in #(( ;; esac - done +done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir @@ -4430,7 +4227,7 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -4444,9 +4241,9 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : +if test "${ac_cv_prog_RANLIB+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -4457,24 +4254,24 @@ 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 + 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_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 + { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4484,9 +4281,9 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -4497,24 +4294,24 @@ 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 + 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_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4523,7 +4320,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -4536,9 +4333,9 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}indent", so it can be a program name with args. set dummy ${ac_tool_prefix}indent; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_INDENT+set}" = set; then : +if test "${ac_cv_prog_INDENT+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$INDENT"; then @@ -4549,24 +4346,24 @@ 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 + 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_INDENT="${ac_tool_prefix}indent" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi INDENT=$ac_cv_prog_INDENT if test -n "$INDENT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INDENT" >&5 + { $as_echo "$as_me:$LINENO: result: $INDENT" >&5 $as_echo "$INDENT" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4576,9 +4373,9 @@ if test -z "$ac_cv_prog_INDENT"; then ac_ct_INDENT=$INDENT # Extract the first word of "indent", so it can be a program name with args. set dummy indent; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_INDENT+set}" = set; then : +if test "${ac_cv_prog_ac_ct_INDENT+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_INDENT"; then @@ -4589,24 +4386,24 @@ 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 + 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_ac_ct_INDENT="indent" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_INDENT=$ac_cv_prog_ac_ct_INDENT if test -n "$ac_ct_INDENT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_INDENT" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_INDENT" >&5 $as_echo "$ac_ct_INDENT" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4615,7 +4412,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -4628,9 +4425,9 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : +if test "${ac_cv_prog_AR+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -4641,24 +4438,24 @@ 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 + 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_AR="${ac_tool_prefix}ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 + { $as_echo "$as_me:$LINENO: result: $AR" >&5 $as_echo "$AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4668,9 +4465,9 @@ if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -4681,24 +4478,24 @@ 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 + 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_ac_ct_AR="ar" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4707,7 +4504,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -4720,9 +4517,9 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mpicc", so it can be a program name with args. set dummy ${ac_tool_prefix}mpicc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_MPI_CC+set}" = set; then : +if test "${ac_cv_prog_MPI_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$MPI_CC"; then @@ -4733,24 +4530,24 @@ 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 + 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_MPI_CC="${ac_tool_prefix}mpicc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi MPI_CC=$ac_cv_prog_MPI_CC if test -n "$MPI_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MPI_CC" >&5 + { $as_echo "$as_me:$LINENO: result: $MPI_CC" >&5 $as_echo "$MPI_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4760,9 +4557,9 @@ if test -z "$ac_cv_prog_MPI_CC"; then ac_ct_MPI_CC=$MPI_CC # Extract the first word of "mpicc", so it can be a program name with args. set dummy mpicc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_MPI_CC+set}" = set; then : +if test "${ac_cv_prog_ac_ct_MPI_CC+set}" = set; then $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MPI_CC"; then @@ -4773,24 +4570,24 @@ 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 + 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_ac_ct_MPI_CC="mpicc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS fi fi ac_ct_MPI_CC=$ac_cv_prog_ac_ct_MPI_CC if test -n "$ac_ct_MPI_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MPI_CC" >&5 + { $as_echo "$as_me:$LINENO: result: $ac_ct_MPI_CC" >&5 $as_echo "$ac_ct_MPI_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4799,7 +4596,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -4811,9 +4608,9 @@ fi # Extract the first word of "install-info", so it can be a program name with args. set dummy install-info; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_INSTALL_INFO+set}" = set; then : +if test "${ac_cv_path_INSTALL_INFO+set}" = set; then $as_echo_n "(cached) " >&6 else case $INSTALL_INFO in @@ -4827,14 +4624,14 @@ for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + 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_path_INSTALL_INFO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS test -z "$ac_cv_path_INSTALL_INFO" && ac_cv_path_INSTALL_INFO="true" @@ -4843,19 +4640,19 @@ esac fi INSTALL_INFO=$ac_cv_path_INSTALL_INFO if test -n "$INSTALL_INFO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_INFO" >&5 + { $as_echo "$as_me:$LINENO: result: $INSTALL_INFO" >&5 $as_echo "$INSTALL_INFO" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "sh", so it can be a program name with args. set dummy sh; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_SHELL+set}" = set; then : +if test "${ac_cv_path_SHELL+set}" = set; then $as_echo_n "(cached) " >&6 else case $SHELL in @@ -4868,14 +4665,14 @@ 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 + 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_path_SHELL="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done - done +done IFS=$as_save_IFS ;; @@ -4883,10 +4680,10 @@ esac fi SHELL=$ac_cv_path_SHELL if test -n "$SHELL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHELL" >&5 + { $as_echo "$as_me:$LINENO: result: $SHELL" >&5 $as_echo "$SHELL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } fi @@ -4903,14 +4700,19 @@ then CXX="${CXX} -mno-cygwin" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lwsock32" >&5 + +{ $as_echo "$as_me:$LINENO: checking for main in -lwsock32" >&5 $as_echo_n "checking for main in -lwsock32... " >&6; } -if test "${ac_cv_lib_wsock32_main+set}" = set; then : +if test "${ac_cv_lib_wsock32_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lwsock32 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -4922,18 +4724,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_wsock32_main=yes else - ac_cv_lib_wsock32_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_wsock32_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_wsock32_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_wsock32_main" >&5 $as_echo "$ac_cv_lib_wsock32_main" >&6; } -if test "x$ac_cv_lib_wsock32_main" = x""yes; then : +if test "x$ac_cv_lib_wsock32_main" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBWSOCK32 1 _ACEOF @@ -4942,14 +4769,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpsapi" >&5 + +{ $as_echo "$as_me:$LINENO: checking for main in -lpsapi" >&5 $as_echo_n "checking for main in -lpsapi... " >&6; } -if test "${ac_cv_lib_psapi_main+set}" = set; then : +if test "${ac_cv_lib_psapi_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpsapi $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -4961,18 +4793,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_psapi_main=yes else - ac_cv_lib_psapi_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_psapi_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_psapi_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_psapi_main" >&5 $as_echo "$ac_cv_lib_psapi_main" >&6; } -if test "x$ac_cv_lib_psapi_main" = x""yes; then : +if test "x$ac_cv_lib_psapi_main" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBPSAPI 1 _ACEOF @@ -4994,14 +4851,19 @@ fi else INSTALL_COMMAND="install_unix" ENABLE_WINCONSOLE="#" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5 + +{ $as_echo "$as_me:$LINENO: checking for sin in -lm" >&5 $as_echo_n "checking for sin in -lm... " >&6; } -if test "${ac_cv_lib_m_sin+set}" = set; then : +if test "${ac_cv_lib_m_sin+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5019,18 +4881,43 @@ return sin (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_m_sin=yes else - ac_cv_lib_m_sin=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_m_sin=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sin" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_sin" >&5 $as_echo "$ac_cv_lib_m_sin" >&6; } -if test "x$ac_cv_lib_m_sin" = x""yes; then : +if test "x$ac_cv_lib_m_sin" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -5039,14 +4926,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 + +{ $as_echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } -if test "${ac_cv_lib_socket_socket+set}" = set; then : +if test "${ac_cv_lib_socket_socket+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5064,18 +4956,43 @@ return socket (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_socket_socket=yes else - ac_cv_lib_socket_socket=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_socket_socket=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } -if test "x$ac_cv_lib_socket_socket" = x""yes; then : +if test "x$ac_cv_lib_socket_socket" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF @@ -5084,14 +5001,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getsockname in -lxnet" >&5 + +{ $as_echo "$as_me:$LINENO: checking for getsockname in -lxnet" >&5 $as_echo_n "checking for getsockname in -lxnet... " >&6; } -if test "${ac_cv_lib_xnet_getsockname+set}" = set; then : +if test "${ac_cv_lib_xnet_getsockname+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lxnet $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5109,18 +5031,43 @@ return getsockname (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_xnet_getsockname=yes else - ac_cv_lib_xnet_getsockname=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_xnet_getsockname=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xnet_getsockname" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_xnet_getsockname" >&5 $as_echo "$ac_cv_lib_xnet_getsockname" >&6; } -if test "x$ac_cv_lib_xnet_getsockname" = x""yes; then : +if test "x$ac_cv_lib_xnet_getsockname" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBXNET 1 _ACEOF @@ -5129,14 +5076,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lstdc++" >&5 + +{ $as_echo "$as_me:$LINENO: checking for main in -lstdc++" >&5 $as_echo_n "checking for main in -lstdc++... " >&6; } -if test "${ac_cv_lib_stdcpp_main+set}" = set; then : +if test "${ac_cv_lib_stdcpp_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lstdc++ $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -5148,18 +5100,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_stdcpp_main=yes else - ac_cv_lib_stdcpp_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_stdcpp_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_stdcpp_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_stdcpp_main" >&5 $as_echo "$ac_cv_lib_stdcpp_main" >&6; } -if test "x$ac_cv_lib_stdcpp_main" = x""yes; then : +if test "x$ac_cv_lib_stdcpp_main" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSTDC__ 1 _ACEOF @@ -5168,14 +5145,18 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5 + { $as_echo "$as_me:$LINENO: checking for main in -lnsl" >&5 $as_echo_n "checking for main in -lnsl... " >&6; } -if test "${ac_cv_lib_nsl_main+set}" = set; then : +if test "${ac_cv_lib_nsl_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -5187,18 +5168,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_nsl_main=yes else - ac_cv_lib_nsl_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_nsl_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_main" >&5 $as_echo "$ac_cv_lib_nsl_main" >&6; } -if test "x$ac_cv_lib_nsl_main" = x""yes; then : +if test "x$ac_cv_lib_nsl_main" = x""yes; then have_nsl=yes else @@ -5209,14 +5215,19 @@ fi if test "$yap_cv_readline" != "no" then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 + +{ $as_echo "$as_me:$LINENO: checking for tgetent in -ltermcap" >&5 $as_echo_n "checking for tgetent in -ltermcap... " >&6; } -if test "${ac_cv_lib_termcap_tgetent+set}" = set; then : +if test "${ac_cv_lib_termcap_tgetent+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltermcap $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5234,18 +5245,43 @@ return tgetent (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_termcap_tgetent=yes else - ac_cv_lib_termcap_tgetent=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_termcap_tgetent=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_tgetent" >&5 $as_echo "$ac_cv_lib_termcap_tgetent" >&6; } -if test "x$ac_cv_lib_termcap_tgetent" = x""yes; then : +if test "x$ac_cv_lib_termcap_tgetent" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBTERMCAP 1 _ACEOF @@ -5254,14 +5290,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lncurses" >&5 + +{ $as_echo "$as_me:$LINENO: checking for main in -lncurses" >&5 $as_echo_n "checking for main in -lncurses... " >&6; } -if test "${ac_cv_lib_ncurses_main+set}" = set; then : +if test "${ac_cv_lib_ncurses_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -5273,18 +5314,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_ncurses_main=yes else - ac_cv_lib_ncurses_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_ncurses_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_main" >&5 $as_echo "$ac_cv_lib_ncurses_main" >&6; } -if test "x$ac_cv_lib_ncurses_main" = x""yes; then : +if test "x$ac_cv_lib_ncurses_main" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBNCURSES 1 _ACEOF @@ -5293,14 +5359,19 @@ _ACEOF fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5 + +{ $as_echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 $as_echo_n "checking for readline in -lreadline... " >&6; } -if test "${ac_cv_lib_readline_readline+set}" = set; then : +if test "${ac_cv_lib_readline_readline+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5318,18 +5389,43 @@ return readline (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_readline_readline=yes else - ac_cv_lib_readline_readline=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_readline_readline=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5 $as_echo "$ac_cv_lib_readline_readline" >&6; } -if test "x$ac_cv_lib_readline_readline" = x""yes; then : +if test "x$ac_cv_lib_readline_readline" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBREADLINE 1 _ACEOF @@ -5341,14 +5437,19 @@ fi fi if test "$yap_cv_gmp" != "no" then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgmp" >&5 + +{ $as_echo "$as_me:$LINENO: checking for main in -lgmp" >&5 $as_echo_n "checking for main in -lgmp... " >&6; } -if test "${ac_cv_lib_gmp_main+set}" = set; then : +if test "${ac_cv_lib_gmp_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgmp $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -5360,18 +5461,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_gmp_main=yes else - ac_cv_lib_gmp_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_gmp_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gmp_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gmp_main" >&5 $as_echo "$ac_cv_lib_gmp_main" >&6; } -if test "x$ac_cv_lib_gmp_main" = x""yes; then : +if test "x$ac_cv_lib_gmp_main" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBGMP 1 _ACEOF @@ -5385,13 +5511,17 @@ fi if test "$yap_cv_myddas" != "no" then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmysqlclient" >&5 + { $as_echo "$as_me:$LINENO: checking for main in -lmysqlclient" >&5 $as_echo_n "checking for main in -lmysqlclient... " >&6; } - if test "${yap_cv_mysql+set}" = set; then : + if test "${yap_cv_mysql+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -5406,15 +5536,36 @@ MYSQL *conn; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_mysql=yes else - yap_cv_mysql=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 "$as_me:$LINENO: result: $yap_cv_mysql" >&5 $as_echo "$yap_cv_mysql" >&6; } if test "$yap_cv_mysql" = yes then @@ -5422,13 +5573,17 @@ $as_echo "$yap_cv_mysql" >&6; } LIBS="$LIBS -L${yap_cv_myddas}/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv " fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lodbc" >&5 + { $as_echo "$as_me:$LINENO: checking for main in -lodbc" >&5 $as_echo_n "checking for main in -lodbc... " >&6; } - if test "${yap_cv_odbc+set}" = set; then : + if test "${yap_cv_odbc+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -5444,15 +5599,36 @@ SQLHENV henv; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_odbc=yes else - yap_cv_odbc=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_odbc=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_odbc" >&5 + { $as_echo "$as_me:$LINENO: result: $yap_cv_odbc" >&5 $as_echo "$yap_cv_odbc" >&6; } if test "$yap_cv_odbc" = yes then @@ -5487,16 +5663,23 @@ fi if test "$threads" = yes then - $as_echo "#define SUPPORT_THREADS 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define SUPPORT_THREADS 1 +_ACEOF - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 + +{ $as_echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } -if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then : +if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5514,18 +5697,43 @@ return pthread_create (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_pthread_pthread_create=yes else - ac_cv_lib_pthread_pthread_create=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_pthread_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + 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 "$as_me:$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" = x""yes; then : +if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF @@ -5539,14 +5747,14 @@ 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 "$as_me:$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 test "${ac_cv_prog_CPP+set}" = set; then : + if test "${ac_cv_prog_CPP+set}" = set; then $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -5561,7 +5769,11 @@ do # 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include @@ -5570,34 +5782,78 @@ do #endif Syntax error _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Broken: fails on valid input. continue fi + rm -f conftest.err 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Passes both tests. ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : +if $ac_preproc_ok; then break fi @@ -5609,7 +5865,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -5620,7 +5876,11 @@ do # 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include @@ -5629,40 +5889,87 @@ do #endif Syntax error _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Broken: fails on valid input. continue fi + rm -f conftest.err 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Passes both tests. ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - +if $ac_preproc_ok; then + : else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:$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; } +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } fi ac_ext=c @@ -5672,9 +5979,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ 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 "$as_me:$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 test "${ac_cv_path_GREP+set}" = set; then : +if test "${ac_cv_path_GREP+set}" = set; then $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -5685,7 +5992,7 @@ 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_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 @@ -5705,7 +6012,7 @@ case `"$ac_path_GREP" --version 2>&1` in $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 + ac_count=`expr $ac_count + 1` 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" @@ -5720,24 +6027,26 @@ esac $ac_path_GREP_found && break 3 done 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 + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:$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 "$as_me:$LINENO: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if test "${ac_cv_path_EGREP+set}" = set; then $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -5751,7 +6060,7 @@ 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_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 @@ -5771,7 +6080,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $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 + ac_count=`expr $ac_count + 1` 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" @@ -5786,10 +6095,12 @@ esac $ac_path_EGREP_found && break 3 done 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 + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP @@ -5797,17 +6108,21 @@ fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:$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 "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -5822,23 +6137,48 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else - ac_cv_header_stdc=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - + $EGREP "memchr" >/dev/null 2>&1; then + : else ac_cv_header_stdc=no fi @@ -5848,14 +6188,18 @@ 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - + $EGREP "free" >/dev/null 2>&1; then + : else ac_cv_header_stdc=no fi @@ -5865,10 +6209,14 @@ 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 : + if test "$cross_compiling" = yes; then : else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -5895,34 +6243,118 @@ main () return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - ac_cv_header_stdc=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +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 +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:$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 +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF 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 -" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5932,24 +6364,247 @@ fi done + 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" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done - for ac_func in pthread_mutexattr_setkind_np pthread_mutexattr_settype -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : + + +for ac_func in pthread_mutexattr_setkind_np pthread_mutexattr_settype +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5959,7 +6614,9 @@ done if test "$pthreadlocking" = yes then - $as_echo "#define USE_PTHREAD_LOCKING 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define USE_PTHREAD_LOCKING 1 +_ACEOF fi use_malloc=yes @@ -6034,14 +6691,18 @@ if test "$yap_cv_mpi" != "no" then OLD_CC=${CC} CC=${MPI_CC} - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI_Init in -lmpi" >&5 + { $as_echo "$as_me:$LINENO: checking for MPI_Init in -lmpi" >&5 $as_echo_n "checking for MPI_Init in -lmpi... " >&6; } -if test "${ac_cv_lib_mpi_MPI_Init+set}" = set; then : +if test "${ac_cv_lib_mpi_MPI_Init+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmpi $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6059,22 +6720,51 @@ return MPI_Init (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_mpi_MPI_Init=yes else - ac_cv_lib_mpi_MPI_Init=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_mpi_MPI_Init=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpi_MPI_Init" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mpi_MPI_Init" >&5 $as_echo "$ac_cv_lib_mpi_MPI_Init" >&6; } -if test "x$ac_cv_lib_mpi_MPI_Init" = x""yes; then : - $as_echo "#define HAVE_LIBMPI 1" >>confdefs.h +if test "x$ac_cv_lib_mpi_MPI_Init" = x""yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPI 1 +_ACEOF else - $as_echo "#define HAVE_LIBMPI 0" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPI 0 +_ACEOF fi @@ -6083,14 +6773,18 @@ fi #YAPMPILIB=YapMPI.a MPI_OBJS=mpi.o else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI_Init in -lmpich" >&5 + { $as_echo "$as_me:$LINENO: checking for MPI_Init in -lmpich" >&5 $as_echo_n "checking for MPI_Init in -lmpich... " >&6; } -if test "${ac_cv_lib_mpich_MPI_Init+set}" = set; then : +if test "${ac_cv_lib_mpich_MPI_Init+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmpich $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6108,22 +6802,51 @@ return MPI_Init (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_mpich_MPI_Init=yes else - ac_cv_lib_mpich_MPI_Init=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_mpich_MPI_Init=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpich_MPI_Init" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mpich_MPI_Init" >&5 $as_echo "$ac_cv_lib_mpich_MPI_Init" >&6; } -if test "x$ac_cv_lib_mpich_MPI_Init" = x""yes; then : - $as_echo "#define HAVE_LIBMPICH 1" >>confdefs.h +if test "x$ac_cv_lib_mpich_MPI_Init" = x""yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPICH 1 +_ACEOF else - $as_echo "#define HAVE_LIBMPICH 0" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPICH 0 +_ACEOF fi @@ -6148,14 +6871,18 @@ if test "$yap_cv_mpi" != "no" -a "$yap_cv_mpe" != "no" then OLD_CC=${CC} CC=${MPI_CC} - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPE_Init_log in -lmpe" >&5 + { $as_echo "$as_me:$LINENO: checking for MPE_Init_log in -lmpe" >&5 $as_echo_n "checking for MPE_Init_log in -lmpe... " >&6; } -if test "${ac_cv_lib_mpe_MPE_Init_log+set}" = set; then : +if test "${ac_cv_lib_mpe_MPE_Init_log+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lmpe $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6173,22 +6900,51 @@ return MPE_Init_log (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_mpe_MPE_Init_log=yes else - ac_cv_lib_mpe_MPE_Init_log=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_mpe_MPE_Init_log=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpe_MPE_Init_log" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_mpe_MPE_Init_log" >&5 $as_echo "$ac_cv_lib_mpe_MPE_Init_log" >&6; } -if test "x$ac_cv_lib_mpe_MPE_Init_log" = x""yes; then : - $as_echo "#define HAVE_LIBMPE 1" >>confdefs.h +if test "x$ac_cv_lib_mpe_MPE_Init_log" = x""yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPE 1 +_ACEOF else - $as_echo "#define HAVE_LIBMPE 0" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBMPE 0 +_ACEOF fi @@ -6205,14 +6961,14 @@ 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 "$as_me:$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 test "${ac_cv_prog_CPP+set}" = set; then : + if test "${ac_cv_prog_CPP+set}" = set; then $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -6227,7 +6983,11 @@ do # 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include @@ -6236,34 +6996,78 @@ do #endif Syntax error _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Broken: fails on valid input. continue fi + rm -f conftest.err 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Passes both tests. ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : +if $ac_preproc_ok; then break fi @@ -6275,7 +7079,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -6286,7 +7090,11 @@ do # 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include @@ -6295,40 +7103,87 @@ do #endif Syntax error _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Broken: fails on valid input. continue fi + rm -f conftest.err 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + # Passes both tests. ac_preproc_ok=: break fi + rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - +if $ac_preproc_ok; then + : else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:$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; } +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } fi ac_ext=c @@ -6342,12 +7197,16 @@ if test "$cross_compiling" = "yes" then YAP_EXTRAS= else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 + { $as_echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } -if test "${ac_cv_header_sys_wait_h+set}" = set; then : +if test "${ac_cv_header_sys_wait_h+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -6368,33 +7227,63 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_sys_wait_h=yes else - ac_cv_header_sys_wait_h=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_sys_wait_h=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then -$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for restartable system calls" >&5 +{ $as_echo "$as_me:$LINENO: checking for restartable system calls" >&5 $as_echo_n "checking for restartable system calls... " >&6; } -if test "${ac_cv_sys_restartable_syscalls+set}" = set; then : +if test "${ac_cv_sys_restartable_syscalls+set}" = set; then $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run test program while cross compiling -See \`config.log' for more details." "$LINENO" 5; } +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Exit 0 (true) if wait returns something other than -1, i.e. the pid of the child, which means that wait was restarted @@ -6436,21 +7325,50 @@ main () return status == -1; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_sys_restartable_syscalls=yes else - ac_cv_sys_restartable_syscalls=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_sys_restartable_syscalls=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_restartable_syscalls" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_restartable_syscalls" >&5 $as_echo "$ac_cv_sys_restartable_syscalls" >&6; } if test $ac_cv_sys_restartable_syscalls = yes; then -$as_echo "#define HAVE_RESTARTABLE_SYSCALLS 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_RESTARTABLE_SYSCALLS 1 +_ACEOF fi @@ -6474,14 +7392,18 @@ case "$target_os" in *linux*) if test "$use_condor" = "no" then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6499,18 +7421,43 @@ return dlopen (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_dl_dlopen=yes else - ac_cv_lib_dl_dlopen=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then have_dl=yes else @@ -6571,7 +7518,9 @@ fi ;; *hpux*) #do not use the first memory quadrant - $as_echo "#define FORCE_SECOND_QUADRANT 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define FORCE_SECOND_QUADRANT 1 +_ACEOF M4="/usr/bin/m4" if test ${use_condor} = no @@ -6592,9 +7541,13 @@ fi # If the xnet library was found, turn on X/Open networking if test "$ac_cv_lib_xnet_getsockname" = yes then - $as_echo "#define _XOPEN_SOURCE 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define _XOPEN_SOURCE 1 +_ACEOF - $as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define _XOPEN_SOURCE_EXTENDED 1 +_ACEOF fi else @@ -6604,7 +7557,9 @@ fi #do not use realloc() from HP-UX 10.20 together with MPI if test ${target_os} = hpux10.20 then - $as_echo "#define MPI_AVOID_REALLOC 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define MPI_AVOID_REALLOC 1 +_ACEOF fi ;; @@ -6619,14 +7574,18 @@ fi *osf*) if ${use_condor} = no then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6644,18 +7603,43 @@ return dlopen (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_dl_dlopen=yes else - ac_cv_lib_dl_dlopen=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then have_dl=yes else @@ -6681,14 +7665,18 @@ fi *darwin*) if test ${use_dlcompat} = yes then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6706,18 +7694,43 @@ return dlopen (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_dl_dlopen=yes else - ac_cv_lib_dl_dlopen=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then have_dl=yes else @@ -6796,14 +7809,18 @@ fi IN_UNIX="#" ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6821,18 +7838,43 @@ return dlopen (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_dl_dlopen=yes else - ac_cv_lib_dl_dlopen=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then have_dl=yes else @@ -6992,13 +8034,17 @@ if test ! "$yap_cv_cplint" = "no" CPLINT_LDFLAGS+=" -L${yap_cv_cplint}/lib" CPLINT_CFLAGS+=" -I${yap_cv_cplint}/include" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing g_hash_table_new" >&5 + { $as_echo "$as_me:$LINENO: checking for library containing g_hash_table_new" >&5 $as_echo_n "checking for library containing g_hash_table_new... " >&6; } -if test "${ac_cv_search_g_hash_table_new+set}" = set; then : +if test "${ac_cv_search_g_hash_table_new+set}" = set; then $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7023,41 +8069,73 @@ for ac_lib in '' glib-2.0; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_search_g_hash_table_new=$ac_res +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if test "${ac_cv_search_g_hash_table_new+set}" = set; then : + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_g_hash_table_new+set}" = set; then break fi done -if test "${ac_cv_search_g_hash_table_new+set}" = set; then : - +if test "${ac_cv_search_g_hash_table_new+set}" = set; then + : else ac_cv_search_g_hash_table_new=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_g_hash_table_new" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_g_hash_table_new" >&5 $as_echo "$ac_cv_search_g_hash_table_new" >&6; } ac_res=$ac_cv_search_g_hash_table_new -if test "$ac_res" != no; then : +if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" CPLINT_LIBS="-lglib-2.0 " else - { as_fn_set_status 1 -as_fn_error "This package needs glib >=2.0." "$LINENO" 5; } + { { $as_echo "$as_me:$LINENO: error: This package needs glib >=2.0." >&5 +$as_echo "$as_me: error: This package needs glib >=2.0." >&2;} + { (exit 1); exit 1; }; } fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing array_do_alloc" >&5 + { $as_echo "$as_me:$LINENO: checking for library containing array_do_alloc" >&5 $as_echo_n "checking for library containing array_do_alloc... " >&6; } -if test "${ac_cv_search_array_do_alloc+set}" = set; then : +if test "${ac_cv_search_array_do_alloc+set}" = set; then $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7082,41 +8160,73 @@ for ac_lib in '' glu; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_search_array_do_alloc=$ac_res +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if test "${ac_cv_search_array_do_alloc+set}" = set; then : + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_array_do_alloc+set}" = set; then break fi done -if test "${ac_cv_search_array_do_alloc+set}" = set; then : - +if test "${ac_cv_search_array_do_alloc+set}" = set; then + : else ac_cv_search_array_do_alloc=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_array_do_alloc" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_array_do_alloc" >&5 $as_echo "$ac_cv_search_array_do_alloc" >&6; } ac_res=$ac_cv_search_array_do_alloc -if test "$ac_res" != no; then : +if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" CPLINT_LIBS="-lglu "$CPLINT_LIBS else - { as_fn_set_status 1 -as_fn_error "This package needs glu." "$LINENO" 5; } + { { $as_echo "$as_me:$LINENO: error: This package needs glu." >&5 +$as_echo "$as_me: error: This package needs glu." >&2;} + { (exit 1); exit 1; }; } fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing Cudd_Init" >&5 + { $as_echo "$as_me:$LINENO: checking for library containing Cudd_Init" >&5 $as_echo_n "checking for library containing Cudd_Init... " >&6; } -if test "${ac_cv_search_Cudd_Init+set}" = set; then : +if test "${ac_cv_search_Cudd_Init+set}" = set; then $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7141,35 +8251,154 @@ for ac_lib in '' cu; do ac_res=-l$ac_lib LIBS="-l$ac_lib -lglu -lm $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_search_Cudd_Init=$ac_res +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if test "${ac_cv_search_Cudd_Init+set}" = set; then : + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_Cudd_Init+set}" = set; then break fi done -if test "${ac_cv_search_Cudd_Init+set}" = set; then : - +if test "${ac_cv_search_Cudd_Init+set}" = set; then + : else ac_cv_search_Cudd_Init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_Cudd_Init" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_Cudd_Init" >&5 $as_echo "$ac_cv_search_Cudd_Init" >&6; } ac_res=$ac_cv_search_Cudd_Init -if test "$ac_res" != no; then : +if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" CPLINT_LIBS="-lcu "$CPLINT_LIBS else - { as_fn_set_status 1 -as_fn_error "This package needs glu." "$LINENO" 5; } + { { $as_echo "$as_me:$LINENO: error: This package needs glu." >&5 +$as_echo "$as_me: error: This package needs glu." >&2;} + { (exit 1); exit 1; }; } fi - ENABLE_CPLINT="" + { $as_echo "$as_me:$LINENO: checking for library containing pow" >&5 +$as_echo_n "checking for library containing pow... " >&6; } +if test "${ac_cv_search_pow+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +for ac_lib in '' m; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib -lglu -lm $ac_func_search_save_LIBS" + fi + 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_search_pow=$ac_res +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_pow+set}" = set; then + break +fi +done +if test "${ac_cv_search_pow+set}" = set; then + : +else + ac_cv_search_pow=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_pow" >&5 +$as_echo "$ac_cv_search_pow" >&6; } +ac_res=$ac_cv_search_pow +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + CPLINT_LIBS="-lm "$CPLINT_LIBS +else + { { $as_echo "$as_me:$LINENO: error: This package needs m." >&5 +$as_echo "$as_me: error: This package needs m." >&2;} + { (exit 1); exit 1; }; } +fi + +ENABLE_CPLINT="" if test "$target_os" = "cygwin" -o "$target_os" = "mingw32" then CPLINT_SHLIB_LD="gcc -shared ../yap.dll" @@ -7190,14 +8419,18 @@ fi # LAM OLD_CC=${CC} CC=${LAM_MPI_CC} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llam" >&5 +{ $as_echo "$as_me:$LINENO: checking for main in -llam" >&5 $as_echo_n "checking for main in -llam... " >&6; } -if test "${ac_cv_lib_lam_main+set}" = set; then : +if test "${ac_cv_lib_lam_main+set}" = set; then $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llam $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ @@ -7209,18 +8442,43 @@ return main (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_lib_lam_main=yes else - ac_cv_lib_lam_main=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_lam_main=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lam_main" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_lam_main" >&5 $as_echo "$ac_cv_lib_lam_main" >&6; } -if test "x$ac_cv_lib_lam_main" = x""yes; then : +if test "x$ac_cv_lib_lam_main" = x""yes; then LAMOBJS=yap_mpi"$SHLIB_SUFFIX" else LAMOBJS=no @@ -7228,12 +8486,16 @@ fi CC=${OLD_CC} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if test "${ac_cv_header_stdc+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -7248,23 +8510,48 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else - ac_cv_header_stdc=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - + $EGREP "memchr" >/dev/null 2>&1; then + : else ac_cv_header_stdc=no fi @@ -7274,14 +8561,18 @@ 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 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - + $EGREP "free" >/dev/null 2>&1; then + : else ac_cv_header_stdc=no fi @@ -7291,10 +8582,14 @@ 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 : + if test "$cross_compiling" = yes; then : else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -7321,31 +8616,64 @@ main () return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - ac_cv_header_stdc=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +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 +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:$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 +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 +{ $as_echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } -if test "${ac_cv_header_sys_wait_h+set}" = set; then : +if test "${ac_cv_header_sys_wait_h+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -7366,27 +8694,186 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_sys_wait_h=yes else - ac_cv_header_sys_wait_h=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_sys_wait_h=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then -$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF fi + + + + + for ac_header in arpa/inet.h ctype.h direct.h dirent.h dlfcn.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7395,12 +8882,146 @@ fi done + + + for ac_header in errno.h fcntl.h fenv.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7409,12 +9030,148 @@ fi done + + + + + for ac_header in float.h fpu_control.h ieeefp.h io.h limits.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7423,12 +9180,148 @@ fi done + + + + + for ac_header in locale.h malloc.h math.h memory.h mpi.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7437,12 +9330,147 @@ fi done + + + + for ac_header in netdb.h netinet/in.h pwd.h regex.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7451,12 +9479,148 @@ fi done + + + + + for ac_header in siginfo.h signal.h stdarg.h string.h stropts.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7465,12 +9629,145 @@ fi done + + for ac_header in sys/conf.h sys/file.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7479,12 +9776,147 @@ fi done + + + + for ac_header in sys/mman.h sys/param.h sys/resource.h sys/select.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7493,12 +9925,146 @@ fi done + + + for ac_header in sys/shm.h sys/socket.h sys/stat.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7507,12 +10073,146 @@ fi done + + + for ac_header in sys/time.h sys/times.h sys/types.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7521,12 +10221,146 @@ fi done + + + for ac_header in sys/ucontext.h sys/un.h sys/wait.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7535,12 +10369,148 @@ fi done + + + + + for ac_header in time.h unistd.h wctype.h winsock.h winsock2.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7549,12 +10519,146 @@ fi done + for ac_header in mach-o/dyld.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "mach-o/dyld.h" "ac_cv_header_mach_o_dyld_h" "$ac_includes_default" -if test "x$ac_cv_header_mach_o_dyld_h" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_MACH_O_DYLD_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7563,12 +10667,146 @@ done if test "$yap_cv_gmp" != "no" then - for ac_header in gmp.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "gmp.h" "ac_cv_header_gmp_h" "$ac_includes_default" -if test "x$ac_cv_header_gmp_h" = x""yes; then : + +for ac_header in gmp.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_GMP_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7578,12 +10816,146 @@ done fi if test "$yap_cv_cudd" != "no" then - for ac_header in cudd.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "cudd.h" "ac_cv_header_cudd_h" "$ac_includes_default" -if test "x$ac_cv_header_cudd_h" = x""yes; then : + +for ac_header in cudd.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_CUDD_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7593,12 +10965,146 @@ done fi if test "$yap_cv_myddas" != "no" then - for ac_header in mysql/mysql.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default" -if test "x$ac_cv_header_mysql_mysql_h" = x""yes; then : + +for ac_header in mysql/mysql.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_MYSQL_MYSQL_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7608,12 +11114,146 @@ done fi if test "$yap_cv_readline" != "no" then - for ac_header in readline/readline.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default" -if test "x$ac_cv_header_readline_readline_h" = x""yes; then : + +for ac_header in readline/readline.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_READLINE_READLINE_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7621,24 +11261,292 @@ fi done fi + for ac_header in mpi.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "mpi.h" "ac_cv_header_mpi_h" "$ac_includes_default" -if test "x$ac_cv_header_mpi_h" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_MPI_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done + for ac_header in mpe.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "mpe.h" "ac_cv_header_mpe_h" "$ac_includes_default" -if test "x$ac_cv_header_mpe_h" = x""yes; then : +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_MPE_H 1 +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi @@ -7646,14 +11554,18 @@ fi done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +{ $as_echo "$as_me:$LINENO: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : +if test "${ac_cv_c_inline+set}" = set; then $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; @@ -7662,17 +11574,41 @@ $ac_kw foo_t foo () {return 0; } #endif _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } + case $ac_cv_c_inline in inline | yes) ;; *) @@ -7688,12 +11624,16 @@ _ACEOF ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +{ $as_echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if test "${ac_cv_struct_tm+set}" = set; then : +if test "${ac_cv_struct_tm+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -7708,18 +11648,41 @@ struct tm tm; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_tm=time.h else - ac_cv_struct_tm=sys/time.h + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_struct_tm=sys/time.h fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then -$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF fi @@ -7727,27 +11690,352 @@ fi # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 +{ $as_echo "$as_me:$LINENO: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if test "${ac_cv_sizeof_int_p+set}" = set; then : +if test "${ac_cv_sizeof_int_p+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int *))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int *))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_int_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int *))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int *))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int *))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_int_p=$ac_lo;; +'') if test "$ac_cv_type_int_p" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (int *) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int *) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (int *) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_int_p=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (int *)); } +static unsigned long int ulongval () { return (long int) (sizeof (int *)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (int *))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (int *)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (int *)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_int_p=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_int_p" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int *) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (int *) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_int_p=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int_p" >&5 $as_echo "$ac_cv_sizeof_int_p" >&6; } @@ -7761,27 +12049,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short int" >&5 +{ $as_echo "$as_me:$LINENO: checking size of short int" >&5 $as_echo_n "checking size of short int... " >&6; } -if test "${ac_cv_sizeof_short_int+set}" = set; then : +if test "${ac_cv_sizeof_short_int+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short int))" "ac_cv_sizeof_short_int" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (short int))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (short int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_short_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (short int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (short int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (short int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_short_int=$ac_lo;; +'') if test "$ac_cv_type_short_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (short int) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (short int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_short_int=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (short int)); } +static unsigned long int ulongval () { return (long int) (sizeof (short int)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (short int))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (short int)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (short int)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_short_int=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_short_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (short int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_short_int=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short_int" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_short_int" >&5 $as_echo "$ac_cv_sizeof_short_int" >&6; } @@ -7795,27 +12408,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 +{ $as_echo "$as_me:$LINENO: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } -if test "${ac_cv_sizeof_int+set}" = set; then : +if test "${ac_cv_sizeof_int+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_int=$ac_lo;; +'') if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (int) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_int=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (int)); } +static unsigned long int ulongval () { return (long int) (sizeof (int)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (int))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (int)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (int)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_int=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_int=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } @@ -7829,27 +12767,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 +{ $as_echo "$as_me:$LINENO: checking size of long int" >&5 $as_echo_n "checking size of long int... " >&6; } -if test "${ac_cv_sizeof_long_int+set}" = set; then : +if test "${ac_cv_sizeof_long_int+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long int))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_long_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long_int=$ac_lo;; +'') if test "$ac_cv_type_long_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (long int) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (long int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_long_int=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (long int)); } +static unsigned long int ulongval () { return (long int) (sizeof (long int)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (long int))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (long int)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (long int)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long_int=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_long_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (long int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_long_int=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_int" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_int" >&5 $as_echo "$ac_cv_sizeof_long_int" >&6; } @@ -7863,27 +13126,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long int" >&5 +{ $as_echo "$as_me:$LINENO: checking size of long long int" >&5 $as_echo_n "checking size of long long int... " >&6; } -if test "${ac_cv_sizeof_long_long_int+set}" = set; then : +if test "${ac_cv_sizeof_long_long_int+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long int))" "ac_cv_sizeof_long_long_int" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long long int))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long long int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_long_long_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long long int))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long long int))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (long long int))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_long_long_int=$ac_lo;; +'') if test "$ac_cv_type_long_long_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (long long int) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long long int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (long long int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_long_long_int=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (long long int)); } +static unsigned long int ulongval () { return (long int) (sizeof (long long int)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (long long int))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (long long int)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (long long int)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_long_long_int=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_long_long_int" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long long int) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (long long int) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_long_long_int=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long_int" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long_int" >&5 $as_echo "$ac_cv_sizeof_long_long_int" >&6; } @@ -7897,27 +13485,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of float" >&5 +{ $as_echo "$as_me:$LINENO: checking size of float" >&5 $as_echo_n "checking size of float... " >&6; } -if test "${ac_cv_sizeof_float+set}" = set; then : +if test "${ac_cv_sizeof_float+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (float))" "ac_cv_sizeof_float" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_float" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (float))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_float=$ac_lo;; +'') if test "$ac_cv_type_float" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (float) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (float) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_float=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (float)); } +static unsigned long int ulongval () { return (long int) (sizeof (float)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (float))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (float)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (float)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_float=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_float" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (float) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_float=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_float" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 $as_echo "$ac_cv_sizeof_float" >&6; } @@ -7931,27 +13844,352 @@ _ACEOF # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 +{ $as_echo "$as_me:$LINENO: checking size of double" >&5 $as_echo_n "checking size of double... " >&6; } -if test "${ac_cv_sizeof_double+set}" = set; then : +if test "${ac_cv_sizeof_double+set}" = set; then $as_echo_n "(cached) " >&6 else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then : + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= 0)]; +test_array [0] = 0 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break else - if test "$ac_cv_type_double" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (double))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_double=$ac_lo;; +'') if test "$ac_cv_type_double" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (double) -See \`config.log' for more details." "$LINENO" 5; }; } +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (double) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } + else + ac_cv_sizeof_double=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +static long int longval () { return (long int) (sizeof (double)); } +static unsigned long int ulongval () { return (long int) (sizeof (double)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (double))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (double)))) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (double)))) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_double=`cat conftest.val` +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_double" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double) +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute sizeof (double) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } else ac_cv_sizeof_double=0 fi fi - +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5 +rm -f conftest.val +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 $as_echo "$ac_cv_sizeof_double" >&6; } @@ -7962,16 +14200,20 @@ _ACEOF -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of malloc" >&5 +{ $as_echo "$as_me:$LINENO: checking for type of malloc" >&5 $as_echo_n "checking for type of malloc... " >&6; } -if test "${yap_cv_malloct+set}" = set; then : +if test "${yap_cv_malloct+set}" = set; then $as_echo_n "(cached) " >&6 else -if test "$cross_compiling" = yes; then : +if test "$cross_compiling" = yes; then yap_cv_malloct=void else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include char *malloc(size_t); @@ -7981,64 +14223,130 @@ else } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then yap_cv_malloct=char else - yap_cv_malloct=void + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +yap_cv_malloct=void fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_malloct *" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_malloct *" >&5 $as_echo "$yap_cv_malloct *" >&6; } if test "$yap_cv_malloct" = void -then $as_echo "#define MALLOC_T void *" >>confdefs.h +then cat >>confdefs.h <<\_ACEOF +#define MALLOC_T void * +_ACEOF -else $as_echo "#define MALLOC_T char *" >>confdefs.h +else cat >>confdefs.h <<\_ACEOF +#define MALLOC_T char * +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc inline" >&5 +{ $as_echo "$as_me:$LINENO: checking for gcc inline" >&5 $as_echo_n "checking for gcc inline... " >&6; } -if test "${yap_cv_gcc+set}" = set; then : +if test "${yap_cv_gcc+set}" = set; then $as_echo_n "(cached) " >&6 else -if test "$cross_compiling" = yes; then : +if test "$cross_compiling" = yes; then yap_cv_gcc=yes else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #undef inline inline int f(int x) {return x+1;} int main() { return 0;} _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then yap_cv_gcc=yes else - yap_cv_gcc=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +yap_cv_gcc=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_gcc" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_gcc" >&5 $as_echo "$yap_cv_gcc" >&6; } if test "$yap_cv_gcc" = yes then M4GENHDRS=m4/gcc_genhdrs.m4 -$as_echo "#define HAVE_GCC 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_GCC 1 +_ACEOF else M4GENHDRS=m4/cc_genhdrs.m4 -$as_echo "#define HAVE_GCC 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_GCC 0 +_ACEOF fi @@ -8109,16 +14417,20 @@ EXEC_SUFFIX="" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc threaded code" >&5 +{ $as_echo "$as_me:$LINENO: checking for gcc threaded code" >&5 $as_echo_n "checking for gcc threaded code... " >&6; } -if test "${yap_cv_threaded_code+set}" = set; then : +if test "${yap_cv_threaded_code+set}" = set; then $as_echo_n "(cached) " >&6 else -if test "$cross_compiling" = yes; then : +if test "$cross_compiling" = yes; then yap_cv_threaded_code=yes else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main() { void *t = &&l2; @@ -8127,26 +14439,57 @@ int main() { } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then yap_cv_threaded_code=yes else - yap_cv_threaded_code=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +yap_cv_threaded_code=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_threaded_code" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_threaded_code" >&5 $as_echo "$yap_cv_threaded_code" >&6; } if test "$yap_cv_threaded_code" = yes && test "$yap_cv_gcc" = yes then - $as_echo "#define USE_THREADED_CODE 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define USE_THREADED_CODE 1 +_ACEOF M4GENABSMI=gen_gcc.m4 else - $as_echo "#define USE_THREADED_CODE 0" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define USE_THREADED_CODE 0 +_ACEOF M4GENABSMI=gen_ansi.m4 fi @@ -8154,16 +14497,20 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IEEE floats" >&5 +{ $as_echo "$as_me:$LINENO: checking for IEEE floats" >&5 $as_echo_n "checking for IEEE floats... " >&6; } -if test "${yap_cv_ffieee+set}" = set; then : +if test "${yap_cv_ffieee+set}" = set; then $as_echo_n "(cached) " >&6 else -if test "$cross_compiling" = yes; then : +if test "$cross_compiling" = yes; then yap_cv_ffieee=yes else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main() { union { float f; int i} a; @@ -8173,35 +14520,70 @@ int main() { } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +rm -f 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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then yap_cv_ffieee=yes else - yap_cv_ffieee=no + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +yap_cv_ffieee=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_ffieee" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_ffieee" >&5 $as_echo "$yap_cv_ffieee" >&6; } if test "$yap_cv_ffieee" = yes then -$as_echo "#define FFIEEE 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define FFIEEE 1 +_ACEOF else -$as_echo "#define FFIEEE 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define FFIEEE 0 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5 +{ $as_echo "$as_me:$LINENO: checking for sigsetjmp" >&5 $as_echo_n "checking for sigsetjmp... " >&6; } -if test "${yap_cv_sigsetjmp+set}" = set; then : +if test "${yap_cv_sigsetjmp+set}" = set; then $as_echo_n "(cached) " >&6 else -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include @@ -8216,32 +14598,61 @@ sigjmp_buf RestartEnv; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_sigsetjmp=yes else - yap_cv_sigsetjmp=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_sigsetjmp=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigsetjmp" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_sigsetjmp" >&5 $as_echo "$yap_cv_sigsetjmp" >&6; } if test "$yap_cv_sigsetjmp" = yes then -$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGSETJMP 1 +_ACEOF else -$as_echo "#define HAVE_SIGSETJMP 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGSETJMP 0 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsegv" >&5 +{ $as_echo "$as_me:$LINENO: checking for sigsegv" >&5 $as_echo_n "checking for sigsegv... " >&6; } -if test "${yap_cv_sigsegv+set}" = set; then : +if test "${yap_cv_sigsegv+set}" = set; then $as_echo_n "(cached) " >&6 else -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -8255,32 +14666,61 @@ printf("Signal value is %d\n", SIGSEGV); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_sigsegv=yes else - yap_cv_sigsegv=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_sigsegv=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigsegv" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_sigsegv" >&5 $as_echo "$yap_cv_sigsegv" >&6; } if test "$yap_cv_sigsegv" = yes then -$as_echo "#define HAVE_SIGSEGV 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGSEGV 1 +_ACEOF else -$as_echo "#define HAVE_SIGSEGV 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGSEGV 0 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigprof" >&5 +{ $as_echo "$as_me:$LINENO: checking for sigprof" >&5 $as_echo_n "checking for sigprof... " >&6; } -if test "${yap_cv_sigprof+set}" = set; then : +if test "${yap_cv_sigprof+set}" = set; then $as_echo_n "(cached) " >&6 else -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -8294,32 +14734,61 @@ printf("Signal value is %d\n", SIGPROF); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_sigprof=yes else - yap_cv_sigprof=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_sigprof=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigprof" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_sigprof" >&5 $as_echo "$yap_cv_sigprof" >&6; } if test "$yap_cv_sigsegv" = yes then -$as_echo "#define HAVE_SIGPROF 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGPROF 1 +_ACEOF else -$as_echo "#define HAVE_SIGPROF 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGPROF 0 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for siginfo" >&5 +{ $as_echo "$as_me:$LINENO: checking for siginfo" >&5 $as_echo_n "checking for siginfo... " >&6; } -if test "${yap_cv_siginfo+set}" = set; then : +if test "${yap_cv_siginfo+set}" = set; then $as_echo_n "(cached) " >&6 else -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -8333,28 +14802,57 @@ printf("SIGINFO value is %d\n", SA_SIGINFO); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then yap_cv_siginfo=yes else - yap_cv_siginfo=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_siginfo=no fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_siginfo" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_siginfo" >&5 $as_echo "$yap_cv_siginfo" >&6; } if test "$yap_cv_siginfo" = yes then -$as_echo "#define HAVE_SIGINFO 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGINFO 1 +_ACEOF else -$as_echo "#define HAVE_SIGINFO 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_SIGINFO 0 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking union wait" >&5 +{ $as_echo "$as_me:$LINENO: checking union wait" >&5 $as_echo_n "checking union wait... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -8371,23 +14869,54 @@ WIFEXITED(x); /* Generates compiler error if WIFEXITED return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 union_wait_ok=yes else - union_wait_ok=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + union_wait_ok=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $union_wait_ok" >&5 + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $union_wait_ok" >&5 $as_echo "$union_wait_ok" >&6; } if test "$union_wait_ok" = no; then - $as_echo "#define NO_UNION_WAIT 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define NO_UNION_WAIT 1 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking environ" >&5 +{ $as_echo "$as_me:$LINENO: checking environ" >&5 $as_echo_n "checking environ... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int @@ -8400,26 +14929,57 @@ extern char **environ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 environ_ok=yes else - environ_ok=no + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + environ_ok=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $environ_ok" >&5 + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $environ_ok" >&5 $as_echo "$environ_ok" >&6; } if test "$environ_ok" = yes; then - $as_echo "#define HAVE_ENVIRON 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define HAVE_ENVIRON 1 +_ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +{ $as_echo "$as_me:$LINENO: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then : +if test "${ac_cv_type_signal+set}" = set; then $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include @@ -8432,14 +14992,35 @@ return *(signal (0, 0)) (0) == 1; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else - ac_cv_type_signal=void + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_signal=void fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF @@ -8447,23 +15028,207 @@ cat >>confdefs.h <<_ACEOF _ACEOF + for ac_func in access -do : - ac_fn_c_check_func "$LINENO" "access" "ac_cv_func_access" -if test "x$ac_cv_func_access" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_ACCESS 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done + + + + + + + for ac_func in acosh asinh atanh chdir ctime dlopen dup2 -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8471,12 +15236,101 @@ _ACEOF fi done + + for ac_func in erf feclearexcept -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8484,12 +15338,106 @@ _ACEOF fi done + + + + + + + for ac_func in fesettrapenable fgetpos finite fpclass ftime getcwd getenv -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8497,12 +15445,102 @@ _ACEOF fi done + + + for ac_func in gethostbyname gethostid gethostname -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8510,12 +15548,101 @@ _ACEOF fi done + + for ac_func in gethrtime getpagesize -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8523,12 +15650,103 @@ _ACEOF fi done + + + + for ac_func in getpwnam getrusage gettimeofday getwd -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8536,12 +15754,106 @@ _ACEOF fi done + + + + + + + for ac_func in isatty isnan isinf kill labs link lgamma -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8549,12 +15861,102 @@ _ACEOF fi done + + + for ac_func in localtime lstat mallinfo -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8562,23 +15964,204 @@ _ACEOF fi done + for ac_func in mbsnrtowcs -do : - ac_fn_c_check_func "$LINENO" "mbsnrtowcs" "ac_cv_func_mbsnrtowcs" -if test "x$ac_cv_func_mbsnrtowcs" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_MBSNRTOWCS 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done + + + + for ac_func in memcpy memmove mkstemp mktemp -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8586,12 +16169,102 @@ _ACEOF fi done + + + for ac_func in nanosleep mktime opendir -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8599,12 +16272,104 @@ _ACEOF fi done + + + + + for ac_func in putenv rand random readlink regexec -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8612,12 +16377,104 @@ _ACEOF fi done + + + + + for ac_func in rename rint rl_set_prompt sbrk select -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8625,12 +16482,103 @@ _ACEOF fi done + + + + for ac_func in setbuf setitimer setlinebuf sigaction -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8638,12 +16586,101 @@ _ACEOF fi done + + for ac_func in siggetmask siginterrupt -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8651,12 +16688,103 @@ _ACEOF fi done + + + + for ac_func in signal sigprocmask socket stat -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8664,12 +16792,105 @@ _ACEOF fi done + + + + + + for ac_func in strchr strerror stricmp strncat strncpy strtod -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8677,12 +16898,104 @@ _ACEOF fi done + + + + + for ac_func in time times tmpnam usleep vsnprintf -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8691,20 +17004,194 @@ fi done -ac_fn_c_check_func "$LINENO" "regexec" "ac_cv_func_regexec" -if test "x$ac_cv_func_regexec" = x""yes; then : +{ $as_echo "$as_me:$LINENO: checking for regexec" >&5 +$as_echo_n "checking for regexec... " >&6; } +if test "${ac_cv_func_regexec+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define regexec to an innocuous variant, in case declares regexec. + For example, HP-UX 11i declares gettimeofday. */ +#define regexec innocuous_regexec + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char regexec (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef regexec + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char regexec (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_regexec || defined __stub___regexec +choke me +#endif + +int +main () +{ +return regexec (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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_cv_func_regexec=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_regexec=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_regexec" >&5 +$as_echo "$ac_cv_func_regexec" >&6; } +if test "x$ac_cv_func_regexec" = x""yes; then NO_BUILTIN_REGEXP="#" else NO_BUILTIN_REGEXP="" fi + for ac_func in NSLinkModule -do : - ac_fn_c_check_func "$LINENO" "NSLinkModule" "ac_cv_func_NSLinkModule" -if test "x$ac_cv_func_NSLinkModule" = x""yes; then : +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF -#define HAVE_NSLINKMODULE 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi @@ -8713,12 +17200,107 @@ done if test "$use_condor" = "no" then - for ac_func in alarm mmap popen shmat sleep system ttyname waitpid -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : + + + + + + + + +for ac_func in alarm mmap popen shmat sleep system ttyname waitpid +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8730,12 +17312,101 @@ fi if test "$target_os" != "mingw32" then - for ac_func in fetestexcept snprintf -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : + + +for ac_func in fetestexcept snprintf +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -8745,13 +17416,17 @@ done fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpz_xor" >&5 +{ $as_echo "$as_me:$LINENO: checking for mpz_xor" >&5 $as_echo_n "checking for mpz_xor... " >&6; } -if test "${yap_cv_mpz_xor+set}" = set; then : +if test "${yap_cv_mpz_xor+set}" = set; then $as_echo_n "(cached) " >&6 else -cat confdefs.h - <<_ACEOF >conftest.$ac_ext +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include void check(mpz_t rop,mpz_t op1,mpz_t op2) { @@ -8766,23 +17441,52 @@ main () return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +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:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + 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 yap_cv_mpz_xor=yes else - yap_cv_mpz_xor=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + yap_cv_mpz_xor=no fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_mpz_xor" >&5 +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi + +{ $as_echo "$as_me:$LINENO: result: $yap_cv_mpz_xor" >&5 $as_echo "$yap_cv_mpz_xor" >&6; } if test "$yap_cv_mpz_xor" = yes then -$as_echo "#define HAVE_MPZ_XOR 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_MPZ_XOR 1 +_ACEOF else -$as_echo "#define HAVE_MPZ_XOR 0" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define HAVE_MPZ_XOR 0 +_ACEOF fi @@ -8791,9 +17495,9 @@ then maxmemory="no" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fflush(NULL) clobbers input pipes" >&5 +{ $as_echo "$as_me:$LINENO: checking if fflush(NULL) clobbers input pipes" >&5 $as_echo_n "checking if fflush(NULL) clobbers input pipes... " >&6; } -if test "${yap_cv_broken_fflush_null+set}" = set; then : +if test "${yap_cv_broken_fflush_null+set}" = set; then $as_echo_n "(cached) " >&6 else cat >conftest.$ac_ext <&5 + { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } if test "$?" = 0 then cat conftest.$ac_ext | ./conftest$ac_exeext > conftest.out { ac_try='cmp conftest.$ac_ext conftest.out' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } if test "$?" = 0 then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:$LINENO: result: no" >&5 $as_echo "no" >&6; } yap_cv_broken_fflush_null=no else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } yap_cv_broken_fflush_null=yes fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 + { $as_echo "$as_me:$LINENO: result: failed" >&5 $as_echo "failed" >&6; } yap_cv_broken_fflush_null=failed fi rm -f conftest.$ac_ext conftest.$ac_objext conftest$ac_exeext conftest.out fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_broken_fflush_null" >&5 +{ $as_echo "$as_me:$LINENO: result: $yap_cv_broken_fflush_null" >&5 $as_echo "$yap_cv_broken_fflush_null" >&6; } if test "$yap_cv_broken_fflush_null" = no then - $as_echo "#define BROKEN_FFLUSH_NULL 0" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define BROKEN_FFLUSH_NULL 0 +_ACEOF else - $as_echo "#define BROKEN_FFLUSH_NULL 1" >>confdefs.h + cat >>confdefs.h <<\_ACEOF +#define BROKEN_FFLUSH_NULL 1 +_ACEOF fi if test "$use_malloc" = yes then -$as_echo "#define USE_SYSTEM_MALLOC 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define USE_SYSTEM_MALLOC 1 +_ACEOF -$as_echo "#define GC_NO_TAGS 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define GC_NO_TAGS 1 +_ACEOF fi if test "$maxmemory" = yes then -$as_echo "#define GC_NO_TAGS 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define GC_NO_TAGS 1 +_ACEOF -$as_echo "#define USE_DL_MALLOC 1" >>confdefs.h +cat >>confdefs.h <<\_ACEOF +#define USE_DL_MALLOC 1 +_ACEOF fi @@ -8903,6 +17619,8 @@ mkdir -p packages/chr mkdir -p packages/CLPBN mkdir -p packages/clpqr mkdir -p packages/cplint +mkdir -p packages/cplint/approx +mkdir -p packages/cplint/approx/simplecuddLPADs mkdir -p packages/jpl mkdir -p packages/jpl/src/java mkdir -p packages/jpl/src/java/jpl @@ -8952,6 +17670,8 @@ ac_config_files="$ac_config_files packages/CLPBN/Makefile" ac_config_files="$ac_config_files packages/cplint/Makefile" +ac_config_files="$ac_config_files packages/cplint/approx/simplecuddLPADs/Makefile" + ac_config_files="$ac_config_files packages/PLStream/Makefile" ac_config_files="$ac_config_files packages/plunit/Makefile" @@ -9015,13 +17735,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; + *) $as_unset $ac_var ;; esac ;; esac done @@ -9029,8 +17749,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -9053,11 +17773,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -9077,8 +17797,8 @@ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -9090,10 +17810,9 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -9103,18 +17822,17 @@ cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false - SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -9122,15 +17840,23 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; esac + fi + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + as_nl=' ' export as_nl @@ -9138,13 +17864,7 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -9155,7 +17875,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in #( + case $arg in *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -9178,6 +17898,13 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -9187,15 +17914,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( +case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done IFS=$as_save_IFS ;; @@ -9207,16 +17934,12 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 + { (exit 1); exit 1; } fi -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' @@ -9228,89 +17951,7 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - +# Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -9324,12 +17965,8 @@ else as_basename=false fi -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -9349,25 +17986,76 @@ $as_echo X/"$0" | } s/.*/./; q'` -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( +case `echo -n x` in -n*) - case `echo 'xy\c'` in + case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; + *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -9396,56 +18084,8 @@ fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' + as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -9464,10 +18104,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in #( + case $1 in -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -9482,19 +18122,13 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to +# Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.63. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -9525,15 +18159,13 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. +\`$as_me' instantiates files from templates according to the +current configuration. -Usage: $0 [OPTION]... [TAG]... +Usage: $0 [OPTION]... [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit - --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -9549,17 +18181,16 @@ $config_files Configuration headers: $config_headers -Report bugs to the package provider." +Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.65, - with options \\"\$ac_cs_config\\" +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2008 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -9594,8 +18225,6 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) @@ -9603,19 +18232,20 @@ do case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - as_fn_append CONFIG_FILES " '$ac_optarg'" + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" + CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; + { $as_echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -9623,10 +18253,11 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; + -*) { $as_echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; - *) as_fn_append ac_config_targets " $1" + *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac @@ -9691,6 +18322,7 @@ do "LGPL/swi_console/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/swi_console/Makefile" ;; "packages/CLPBN/Makefile") CONFIG_FILES="$CONFIG_FILES packages/CLPBN/Makefile" ;; "packages/cplint/Makefile") CONFIG_FILES="$CONFIG_FILES packages/cplint/Makefile" ;; + "packages/cplint/approx/simplecuddLPADs/Makefile") CONFIG_FILES="$CONFIG_FILES packages/cplint/approx/simplecuddLPADs/Makefile" ;; "packages/PLStream/Makefile") CONFIG_FILES="$CONFIG_FILES packages/PLStream/Makefile" ;; "packages/plunit/Makefile") CONFIG_FILES="$CONFIG_FILES packages/plunit/Makefile" ;; "packages/ProbLog/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/Makefile" ;; @@ -9704,7 +18336,9 @@ do "packages/swi-minisat2/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/Makefile" ;; "packages/swi-minisat2/C/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/C/Makefile" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; esac done @@ -9730,7 +18364,7 @@ $debug || trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 - trap 'as_fn_exit 1' 1 2 13 15 + trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. @@ -9741,7 +18375,11 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || +{ + $as_echo "$as_me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -9749,16 +18387,10 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi +ac_cr=' ' ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi @@ -9772,18 +18404,24 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -9805,7 +18443,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\)..*/\1/ +s/\(.\{148\}\).*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -9819,7 +18457,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\)..*/\1/ +s/\(.\{148\}\).*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -9872,7 +18510,9 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), @@ -9913,7 +18553,9 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} + { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -9998,7 +18640,9 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 +$as_echo "$as_me: error: could not setup config headers machinery" >&2;} + { (exit 1); exit 1; }; } fi # test -n "$CONFIG_HEADERS" @@ -10011,7 +18655,9 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} + { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -10039,10 +18685,12 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" + ac_file_inputs="$ac_file_inputs '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -10053,7 +18701,7 @@ do `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -10066,7 +18714,9 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; esac ;; esac @@ -10094,7 +18744,47 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in @@ -10146,6 +18836,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= + ac_sed_dataroot=' /datarootdir/ { p @@ -10155,11 +18846,12 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p' +/@mandir@/p +' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -10169,7 +18861,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -10197,12 +18889,14 @@ s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} @@ -10212,7 +18906,9 @@ which seems to be undefined. Please make sure it is defined." >&2;} -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; :H) # @@ -10223,19 +18919,25 @@ which seems to be undefined. Please make sure it is defined." >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 + { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 +$as_echo "$as_me: error: could not create -" >&2;} + { (exit 1); exit 1; }; } fi ;; @@ -10245,12 +18947,15 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;} done # for ac_tag -as_fn_exit 0 +{ (exit 0); exit 0; } _ACEOF +chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } # configure is writing to config.log, and then calls config.status. @@ -10271,10 +18976,10 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || { (exit 1); exit 1; } fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/configure.in b/configure.in index 1f4ea7265..9880697e0 100755 --- a/configure.in +++ b/configure.in @@ -1140,7 +1140,8 @@ if test ! "$yap_cv_cplint" = "no" AC_SEARCH_LIBS([g_hash_table_new], [glib-2.0], [CPLINT_LIBS="-lglib-2.0 "], [AC_MSG_ERROR([This package needs glib >=2.0.], [1])], []) AC_SEARCH_LIBS([array_do_alloc], [glu], [CPLINT_LIBS="-lglu "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs glu.], [1])], []) AC_SEARCH_LIBS([Cudd_Init], [cu], [CPLINT_LIBS="-lcu "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs glu.], [1])], [-lglu -lm]) - ENABLE_CPLINT="" + AC_SEARCH_LIBS([pow], [m], [CPLINT_LIBS="-lm "$CPLINT_LIBS], [AC_MSG_ERROR([This package needs m.], [1])], [-lglu -lm]) +ENABLE_CPLINT="" if test "$target_os" = "cygwin" -o "$target_os" = "mingw32" then CPLINT_SHLIB_LD="gcc -shared ../yap.dll" @@ -1633,6 +1634,8 @@ mkdir -p packages/chr mkdir -p packages/CLPBN mkdir -p packages/clpqr mkdir -p packages/cplint +mkdir -p packages/cplint/approx +mkdir -p packages/cplint/approx/simplecuddLPADs mkdir -p packages/jpl mkdir -p packages/jpl/src/java mkdir -p packages/jpl/src/java/jpl @@ -1664,6 +1667,7 @@ AC_CONFIG_FILES([LGPL/clp/Makefile]) AC_CONFIG_FILES([LGPL/swi_console/Makefile]) AC_CONFIG_FILES([packages/CLPBN/Makefile]) AC_CONFIG_FILES([packages/cplint/Makefile]) +AC_CONFIG_FILES([packages/cplint/approx/simplecuddLPADs/Makefile]) AC_CONFIG_FILES([packages/PLStream/Makefile]) AC_CONFIG_FILES([packages/plunit/Makefile]) AC_CONFIG_FILES([packages/ProbLog/Makefile ]) diff --git a/packages/cplint/Makefile.in b/packages/cplint/Makefile.in index 7a6e3ec2c..fabf636c2 100644 --- a/packages/cplint/Makefile.in +++ b/packages/cplint/Makefile.in @@ -3,16 +3,17 @@ # (EROOT for architecture-dependent files) # prefix = @prefix@ +exec_prefix = ${prefix} ROOTDIR = $(prefix) -EROOTDIR = @exec_prefix@ +EROOTDIR = ${prefix} # # where the binary should be # -BINDIR = $(ROOTDIR)/bin +BINDIR = $(EROOTDIR)/bin # # where YAP should look for libraries # -LIBDIR=@libdir@/Yap +YAPLIBDIR=${exec_prefix}/lib/Yap # # where YAP should look for architecture-independent Prolog libraries # @@ -20,7 +21,7 @@ SHAREDIR=$(ROOTDIR)/share/Yap # # CC=@CC@ -CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I$(srcdir)/../include +CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I$(srcdir)/../../include # # # You shouldn't need to change what follows. @@ -57,7 +58,18 @@ CPLINT_PROGRAMS= \ $(CPLINT_SRCDIR)/lpadclpbn.pl \ $(CPLINT_SRCDIR)/lpadsld.pl \ $(CPLINT_SRCDIR)/lpad.pl \ - $(CPLINT_SRCDIR)/cpl.pl + $(CPLINT_SRCDIR)/cpl.pl \ + $(CPLINT_SRCDIR)/approx/bestfirst.pl \ + $(CPLINT_SRCDIR)/approx/bestk.pl \ + $(CPLINT_SRCDIR)/approx/deepdyn.pl \ + $(CPLINT_SRCDIR)/approx/deepit.pl \ + $(CPLINT_SRCDIR)/approx/exact.pl \ + $(CPLINT_SRCDIR)/approx/exact_mem.pl \ + $(CPLINT_SRCDIR)/approx/montecarlo.pl \ + $(CPLINT_SRCDIR)/approx/params.pl \ + $(CPLINT_SRCDIR)/approx/parsing.pl \ + $(CPLINT_SRCDIR)/approx/tptreefile.pl \ + $(CPLINT_SRCDIR)/approx/utility.pl CPLINT_SEMANTICS_PROGRAMS= \ $(CPLINT_SRCDIR)/semlpadsld.pl \ @@ -67,7 +79,6 @@ CPLINT_SEMANTICS_PROGRAMS= \ CPLINT_TEST_PROGRAMS= \ $(CPLINT_SRCDIR)/testlpadvel.pl \ - $(CPLINT_SRCDIR)/testlpadclpbn.pl \ $(CPLINT_SRCDIR)/testlpadsld_gbtrue.pl \ $(CPLINT_SRCDIR)/testlpadsld_gbfalse.pl \ $(CPLINT_SRCDIR)/testlpad.pl \ @@ -157,10 +168,11 @@ install: all for h in $(CPLINT_DOCS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/cplint/doc; done for h in $(CPLINT_TEST_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/cplint; done for h in $(CPLINT_SEMANTICS_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done - $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(LIBDIR) + $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR) + $(INSTALL_PROGRAM) approx/simplecuddLPADs/LPADBDD $(SHAREDIR) installcheck: - for h in ${CPLINT_TEST_PROGRAMS}; do echo "t. halt." | yap -l $$h; done + for h in ${CPLINT_TEST_PROGRAMS}; do echo "t. halt." | $(BINDIR)/yap -l $$h; done # use the following target to run individual tests, e.g. make testlpad test%: diff --git a/packages/cplint/approx/.svn/all-wcprops b/packages/cplint/approx/.svn/all-wcprops new file mode 100644 index 000000000..5bde043e7 --- /dev/null +++ b/packages/cplint/approx/.svn/all-wcprops @@ -0,0 +1,77 @@ +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/cplint/!svn/ver/2160/cplint/trunk/cplint_new/approx_src +END +bestfirst.pl +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/bestfirst.pl +END +bestk.pl +K 25 +svn:wc:ra_dav:version-url +V 69 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/bestk.pl +END +deepdyn.pl +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/deepdyn.pl +END +deepit.pl +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/deepit.pl +END +INSTALL.txt +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/cplint/!svn/ver/2160/cplint/trunk/cplint_new/approx_src/INSTALL.txt +END +exact_mem.pl +K 25 +svn:wc:ra_dav:version-url +V 73 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/exact_mem.pl +END +montecarlo.pl +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/montecarlo.pl +END +params.pl +K 25 +svn:wc:ra_dav:version-url +V 70 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/params.pl +END +parsing.pl +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/parsing.pl +END +tptreefile.pl +K 25 +svn:wc:ra_dav:version-url +V 74 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/tptreefile.pl +END +utility.pl +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/utility.pl +END +exact.pl +K 25 +svn:wc:ra_dav:version-url +V 69 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/exact.pl +END diff --git a/packages/cplint/approx/.svn/entries b/packages/cplint/approx/.svn/entries new file mode 100644 index 000000000..f741cd769 --- /dev/null +++ b/packages/cplint/approx/.svn/entries @@ -0,0 +1,446 @@ +9 + +dir +2205 +https://ds.ing.unife.it/svn/cplint/cplint/trunk/cplint_new/approx_src +https://ds.ing.unife.it/svn/cplint + + + +2010-03-15T10:52:08.979119Z +2160 +friguzzi + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +8b881860-fc2d-0410-9739-81b0d24abadf + + + + + + +0 + +bestfirst.pl +file + + + + +2010-03-15T10:10:51.000000Z +cc0ab0375af7a0d3f1075283af40bb42 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +16349 + +deepdyn.pl +file + + + + +2010-03-15T10:12:51.000000Z +bae676b92cbfdf9e1a534312d701c56b +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +12041 + +bestk.pl +file + + + + +2010-03-15T10:12:37.000000Z +10bc1754eaa5ed354b87686f4b44ef42 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +19626 + +deepit.pl +file + + + + +2010-03-15T10:13:06.000000Z +7bf0b9c071d33fcf01ed31fc2a21dfc8 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +12009 + +INSTALL.txt +file + + + + +2010-03-15T10:51:58.000000Z +995b2f3c1195b166dd28147e3a36db71 +2010-03-15T10:52:08.979119Z +2160 +friguzzi + + + + + + + + + + + + + + + + + + + + + +354 + +exact_mem.pl +file + + + + +2010-03-15T10:09:31.000000Z +a83ce974957436d11f61969a5024dd99 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +5546 + +montecarlo.pl +file + + + + +2010-03-15T10:09:31.000000Z +d97412d0fe41b3af1357e5a01d7e04b1 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +9140 + +utility.pl +file + + + + +2010-03-15T10:09:31.000000Z +26ae6e67bf10751c653519db4037e3d2 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +9698 + +simplecuddLPADs +dir + +params.pl +file + + + + +2010-03-15T10:09:31.000000Z +1ef52cf23908247415d2852252ad766a +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +2999 + +parsing.pl +file + + + + +2010-03-15T10:09:31.000000Z +7b1ae7dc7abf91883ec268a0d45744a6 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +9148 + +tptreefile.pl +file + + + + +2010-03-15T10:09:31.000000Z +02811461bc732d74a68b1b8572116370 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +18024 + +exact.pl +file + + + + +2010-03-15T10:13:20.000000Z +f2bd2e1315dc70c787f3abd14af17539 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +6731 + diff --git a/packages/cplint/approx/.svn/format b/packages/cplint/approx/.svn/format new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/packages/cplint/approx/.svn/format @@ -0,0 +1 @@ +9 diff --git a/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base b/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base new file mode 100644 index 000000000..1af57a681 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base @@ -0,0 +1,5 @@ +To use the algorithms, you have to compile simplecudd for LPADs in folder +simplecuddLPADs. Modify the makefile provided to suit your machine and run +make, make install. Please note that glu is a library that includes cudd and +that is distributed with vis http://vlsi.colorado.edu/~vis/. +Instead of linking with libglu.a, you can link with libcudd-ver.a. diff --git a/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base b/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base new file mode 100644 index 000000000..8f5cf20ee --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base @@ -0,0 +1,451 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) + * ------------------------------------------------------ + * This predicate computes the probability of a given list of goals using an + * iterative deepening, probability bounded algorithm. + * It also returns the number of handled BDDs and the CPUTime spent performing + * resolution and spent handling the BDDs. + * + * Note: when their derivation is cut, negative goals are added to the head of + * the goals' list to be solved during the following iteration. + * + * INPUT + * - GoalsList: given list of goal to work on. It can contains variables: the + * predicate returns in backtracking all the solutions and their equivalent + * lower and upper bound probability. + * + * OUTPUT + * - ProbLow: resulting lower bound probability for the given list of goals. + * - ProbUp: resulting upper bound probability for the given list of goals. + * - Count: number of BDDs generated by the algorithm. + * - ResTime: CPU time spent on performing resolution. + * - BddTime: CPU time spent on handling BDDs. + */ +solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) :- + setting(k, K), + setting(min_error, MinError), + setting(prob_step, ProbStep), + + ProbStepLog is log(ProbStep), + + assert(low(0, 0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + bestfirst([0.0-([], [], Goals)], 0, K, MinError, ProbStepLog, ProbLow, ProbUp, 0, Count, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_, _)), + retract(up(_)). + + + +/* bestfirst(GoalsList, Number, Amount, MinError, ProbStep, + * LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) + * ----------------------------------------------------------------------------- + * This recursive supporting predicate performs resolution for current iteration, + * handles equivalent BDDs (lower and upper one) and calls itself if the current + * probability error is still bigger than the given minimum error. + * + * INPUT + * - GoalsList: given list of goal to work on. + * - FoundList: given list of achieved solutions. + * - Amount: max number of solution considered by each iteration. + * - MinError: minimum error (closing condition). + * - ProbStep: probability step. + * - Count0: number of BDDs already handled by the algorithm. + * - ResTime0: cpu time already spent on performing resolution. + * - BddTime0: cpu time already spent on handling BDDs. + * + * OUTPUT + * - LowerProb1: resulting lower bound probability for the given list of goals. + * - UpperProb1: resulting upper bound probability for the given list of goals. + * - Count1: number of BDDs handled. + * - ResTime1: cpu time spent on performing resolution. + * - BddTime1: cpu time spent on handling BDDs. + */ +bestfirst(GoalsList, Number, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + main(GoalsList, Amount, ProbStep, List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + Count2 is Count0 + 2, + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + Count1 = Count2, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + bestfirst(Incomplete, Next, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count2, Count1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* main(GoalsList, Amount, ProbStep, Pending) + * ------------------------------------------------ + * This tail recursive predicate takes the given GoalsList and tries to solve + * the first given Amount quads with the given ProbStep bound on probability, + * one at a time. After each resolution step, it merges the new solutions to the + * current list of solutions so that each time it can consider the most + * promising solution. It finally returns the list of pending solutions, if any. + * + * INPUT + * - GoalsList: current list of goals to solve. + * - Amount: current number of goals to solve. + * - ProbStep: incremental probability step for bound. + * + * OUTPUT + * - Sorted: desired sorted (by non increasing prob) results. + */ +main([], _Amount, _Step, []) :- !. +%% Closing condition: stop if no more goals (pending list is an empty list). + +main(Pending, Amount, _Step, Pending) :- + Amount =< 0, !. + %% Closing condition: stop if reached desired amount (pending list is current list). + +main([Prob0-(Gnd0, Var0, Goals0)|Tail], Amount, Step, Pending) :- + %% Note: Current list is surely not empty. + %% Note: A certain amount is surely still needed. + Bound is Prob0 + Step, + findall(Prob1-(Gnd1, Var1, Goals1), + explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)), + List), + %% Find all the solutions reacheable from the first quad. + sort(List, Sorted), + merge(Tail, Sorted, Complete), + + Needed is Amount - 1, + %% Count current quad as considered. + main(Complete, Needed, Step, Pending). + %% Recursive call: consider next quad (updating pending list). + %% Note: Complete list is sorted; this assures we always consider best quad. + + + +/* merge(SortedA, SortedB, Sorted) + * ------------------------------- + * This tail recursive predicate merges the quads in SortedA and SortedB list by + * non-increasing values of Prob and returns the desired unique Sorted list. + * The SortedA and SortedB lists must be sorted. + * + * INPUT + * - SortedA: first sorted list of quads. + * - SortedB: second sorted list of quads. + * + * OUTPUT + * - Sorted: resulting unique sorted list of quads. + */ +merge(Sorted, [], Sorted) :- !. +%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). + +merge([], Sorted, Sorted). +%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). + +merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbA-(GndA, VarA, GoalsA)|Tail]) :- + ProbA >= ProbB, !, + merge(TailA, [ProbB-(GndB, VarB, GoalsB)|TailB], Tail). + %% Recursive call: use the first quad (merge the rest of the first list with the second one). + +merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbB-(GndB, VarB, GoalsB)|Tail]) :- +% ProbA < ProbB, !, + merge([ProbA-(GndA, VarA, GoalsA)|TailA], TailB, Tail). + %% Recursive call: use the second quad (merge the first list with the rest of the second one). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base b/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base new file mode 100644 index 000000000..7a47c8fd5 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base @@ -0,0 +1,528 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(Goals, Prob, ResTime, BddTime) + * ------------------------------------ + * This predicate computes the probability of a given list of goals using an + * iterative deepening, probability bounded algorithm. + * It also returns the number of handled BDDs and the CPUTime spent performing + * resolution and spent handling the BDDs. + * + * Note: when their derivation is cut, negative goals are added to the head of + * the goals' list to be solved during the following iteration. + * + * INPUT + * - GoalsList: given list of goal to work on. It can contains variables: the + * predicate returns in backtracking all the solutions and their equivalent + * lower and upper bound probability. + * + * OUTPUT + * - Prob: resulting lower bound probability for the given list of goals. + * - ResTime: CPU time spent on performing resolution. + * - BddTime: CPU time spent on handling BDDs. + */ +solve(Goals, Prob, ResTime, BddTime) :- + setting(k, K), + setting(prob_step, ProbStep), + ProbStepLog is log(ProbStep), + % NB: log(1.0) == 0.0 !!! + bestk([0.0-0.0-([], [], Goals)], K, ProbStepLog, Prob, ResTime, BddTime). + + + +/* bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) + * ----------------------------------------------------- + * This recursive supporting predicate performs resolution for current iteration, + * sticks with the best complete solutions only and considers their equivalent + * BDD to compute their probability. + * + * INPUT + * - GoalsList: given list of goal to work on. + * - K: number of solution to consider. + * - ProbStep: value used to update the probability bound. + * + * OUTPUT + * - Prob: resulting probability (actaully a lower bound) for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + main(GoalsList, K, ProbStep, BestK), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(1), + insert_full_ptree(BestK, 1), + bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), + delete_ptree(1), + run_file('bdd.txt','bdd.par', Temp), + (Temp == timeout -> + Prob is -1.0; + Prob is Temp), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime is (ElapBddTime / 1000). + + + +/* main(Goals, K, ProbStep, Best) + * ------------------------------ + * This tail recursive predicate returns the Best K complete solutions to the + * given Goals. The probability bound is dinamically computed at each iteration. + * + * INPUT + * - Goals: list of goals to achive. + * - K: desired number of solutions. + * - ProbStep: value used to update the probability bound. + * + * OUTPUT + * - Best: list of best solutions (at most k). + */ +main(Goals, K, ProbStep, Best) :- + K > 0, + main(Goals, ProbStep, K, 0.0, [], Best). + +main([], _ProbStep, _Left, _Worst, Best, Best). + +main(Goals, ProbStep, Left0, Worst0, Best0, Best1) :- + findall(Prob1-Bound-(Gnd1, Var1, Goals1), + (member(Prob0-Bound0-(Gnd0, Var0, Goals0), Goals), Bound is Bound0+ ProbStep, explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + Found), + %% sepkeepbest(Found, Left0, Left2, Worst0, Worst2, Best0, Best2, [], Incomplete), + separate_main(Found, [], Complete, [], _UpperList, [], Incomplete), + keepbest(Complete, Left0, Left2, Worst0, Worst2, Best0, Best2), + main(Incomplete, ProbStep, Left2, Worst2, Best2, Best1). + + + +/* sepkeepbest(Found, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) + * ---------------------------------------------------------------------------- + * This tail recursive predicate analyzes the given list of solutions found and + * returns the list of (K at most) best complete solutions and the whole list of + * incomplete solutions for a full B&B behaviour. + * The given worst value permits some optimization, such as immediate skipping + * of very bad solutions. + * + * INPUT + * - Found: list of solutions found. + * - Left0: actual amount of items still needed to have K solutions. + * - Worst0: value of the actual worst complete solution kept. + * - List0: actual list of best complete solutions. + * - Next0: actual list of incomplete solutions. + * + * OUTPUT + * - Left1: final amount of items still needed to have K solutions. + * - Worst1: value of the final worst complete solution kept. + * - List1: final list of best complete solutions. + * - Next1: final list of incomplete solutions. + */ +sepkeepbest([], Left, Left, Worst, Worst, List, List, Next, Next) :- !. +%% Closing condition: stop if no more results (current values are now final values). + +sepkeepbest([Prob0-(_Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- + Prob0 =< Worst0, !, + sepkeepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- + Prob0 > Worst0, !, + discard(Prob0-(Gnd0, [], []), List0, List2, Worst2), + sepkeepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, [], [])|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- !, + insert(Prob0-(Gnd0, [], []), List0, Worst0, List2, Worst2), + Left2 is Left0 - 1, + sepkeepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, Var0, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + sepkeepbest(Tail, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). + + + +/* separate(List, Low, Up, Next) + * ----------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([Prob0-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-(Gnd0, Var0, Goals)|Next1]) :- + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate_main([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate_main([Prob0-_Bound0-(Gnd0, [], [])|Tail], Low0, [Prob0-(Gnd0, [], [])|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, + separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate_main([Prob0-Bound0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Next1]) :- + separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_prob(Var, 1, Prob), + append(Gnd0, Var, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, [], Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_prob(Var, 1, Prob), + append(Gnd0, Var, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, [], Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* keepbest(List, K, BestK) + * ------------------------ + * This tail recursive predicate parses the given list of quads and returns the + * list of its best k quads. If the given list of quads contains less than k + * items, the predicate returns them all. + * + * INPUT + * - List: list of quads to parse. + * - K: desired number of quads. + * + * OUTPUT + * - BestK: final list of (at most) best k quads. + */ +keepbest(List, K, BestK) :- + K > 0, + keepbest(List, K, _Left, 0.0, _Worst, [], BestK). + +/*keepbest([], _Left, _Worst, List, List). + +keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Worst, List0, List1) :- + Prob =< Worst, !, + keepbest(Tail, 0, Worst, List0, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Worst, List0, List1) :- + Prob > Worst, !, + discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), + keepbest(Tail, 0, Worst2, List2, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], Left, Worst, List0, List1) :- + insert(Prob-(Gnd, Var, Goals), List0, Worst, List2, Worst2), + Left2 is Left - 1, + keepbest(Tail, Left2, Worst2, List2, List1).*/ + + + +keepbest([], Left, Left, Worst, Worst, List, List). + +keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- + Prob =< Worst0, !, + keepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- + Prob > Worst0, !, + discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), + keepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1) :- + insert(Prob-(Gnd, Var, Goals), List0, Worst0, List2, Worst2), + Left2 is Left0 - 1, + keepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1). + + + +/* insert(Prob-(Gnd, Var, Goals), Sorted0, Worst0, Sorted1, Worst1) + * ---------------------------------------------------------------- + * This tail recursive predicate inserts the given quad into the given sorted + * list and returns the final sorted list. The input list must be sorted. + * It also updates the prob value of the worst quad. + * + * INPUT + * - Prob-(Gnd, Var, Goals): quad to insert. + * - Sorted0: sorted list to insert the quad into. + * - Worst0: current worst prob value. + * + * OUTPUT + * - Sorted1: the final sorted list. + * - Worst1: the final worst prob value. + */ +insert(Prob-(Gnd, Var, Goals), [], _Worst, [Prob-(Gnd, Var, Goals)], Prob). + +insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst, [Prob-(Gnd, Var, Goals), Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst) :- + Prob >= Prob_i, !. + +insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst0, [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst1) :- + Prob < Prob_i, !, + insert(Prob-(Gnd, Var, Goals), Tail, Worst0, Next, Worst1). + + + +/* discard(Prob-(Gnd, Var, Goals), Sorted0, Sorted1, Worst) + * -------------------------------------------------------- + * This tail recursive predicate inserts the given quad into the given sorted + * list, removes the last quad from it and returns the final sorted list. + * The given sorted list contains at least one quad and must be sorted. + * Previous worst prob value is not needed because it necessarely changes and + * the new value is not known in advance. + * It also updates the prob value of the worst quad. + * + * INPUT + * - Prob-(Gnd, Var, Goals): quad to insert. + * - Sorted0: sorted list to insert the quad into. + * + * OUTPUT + * - Sorted1: the final sorted list. + * - Worst: the final worst prob value. + */ +discard(Prob-(Gnd, Var, Goals), [_Prob_i-(_Gnd_i, _Var_i, _Goals_i)], [Prob-(Gnd, Var, Goals)], Prob) :- !. + +discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob-(Gnd, Var, Goals)|Next], Worst) :- + Prob >= Prob_i, !, + discard(Prob_i-(Gnd_i, Var_i, Goals_i), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). + +discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst) :- + Prob < Prob_i, !, + discard(Prob-(Gnd, Var, Goals), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_full_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the ground part of the given list in a trie. + */ +insert_full_ptree([], _Trie). + +insert_full_ptree([_Prob-(Gnd, _Var, _Goals)|Tail], Trie) :- + reverse(Gnd, Gnd1), + insert_ptree(Gnd1, Trie), + insert_full_ptree(Tail, Trie). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). + + diff --git a/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base b/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base new file mode 100644 index 000000000..8bdb8b981 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base @@ -0,0 +1,352 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File deepit.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) + * --------------------------------------------------- + * This predicate computes the probability of a given list of goals using an + * iterative deepening algorithm. It also returns the number of handled BDDs and + * CPUTime spent in performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - ProbLow: the resulting lowerbound probability for the given list of goals. + * - ProbUp: the resulting upperbound probability for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- + setting(min_error, MinError), + setting(prob_step, ProbStep), + + LogProbStep is log(ProbStep), + + assert(low(0,0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + deepdyn([0.0-([], [], GoalsList)], 0, MinError, LogProbStep, ProbLow, ProbUp, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_,_)), + retract(up(_)). + + + +/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where +CG is the list of ground choices, C is the list of non-ground choices, +P is the probability of CG, G is the list of goals to be resolved, +Succ is the list of explanations found so far, PB is the current prob bound, +ProbL0,ProbU0 are the lower/upper prob bounds */ + +deepdyn(GoalsList, Number, MinError, ProbStep, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Prob1-(Gnd1, Var1, Goals1), + (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), ProbBound is log(Prob0) + ProbStep, explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + deepdyn(Incomplete, Next, MinError, ProbStep, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base b/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base new file mode 100644 index 000000000..52c71047c --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base @@ -0,0 +1,352 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File deepit.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) + * --------------------------------------------------- + * This predicate computes the probability of a given list of goals using an + * iterative deepening algorithm. It also returns the number of handled BDDs and + * CPUTime spent in performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - ProbLow: the resulting lowerbound probability for the given list of goals. + * - ProbUp: the resulting upperbound probability for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- + setting(min_error, MinError), + setting(prob_bound, ProbBound), + + LogProbBound is log(ProbBound), + + assert(low(0,0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + deepit([0.0-([], [], GoalsList)], 0, MinError, LogProbBound, ProbLow, ProbUp, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_,_)), + retract(up(_)). + + + +/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where +CG is the list of ground choices, C is the list of non-ground choices, +P is the probability of CG, G is the list of goals to be resolved, +Succ is the list of explanations found so far, PB is the current prob bound, +ProbL0,ProbU0 are the lower/upper prob bounds */ + +deepit(GoalsList, Number, MinError, ProbBound, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Prob1-(Gnd1, Var1, Goals1), + (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + deepit(Incomplete, Next, MinError, ProbBound, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/exact.pl.svn-base b/packages/cplint/approx/.svn/text-base/exact.pl.svn-base new file mode 100644 index 000000000..ead21b34c --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/exact.pl.svn-base @@ -0,0 +1,235 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, Prob, ResTime, BddTime) + * ---------------------------------------- + * This predicate computes the probability of a given list of goals using an + * exact algorithm. It also returns the number of handled BDDs (trivial but + * present for simmetry with other solving predicates), CPUTime spent in + * performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - Prob: the resulting exact probability for the given list of goals. + * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Deriv, exact(GoalsList, Deriv), List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(1), + fatto(List), + insert_list_ptree(List, 1), + bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), + delete_ptree(1), + run_file('bdd.txt','bdd.par', Temp), + (Temp == timeout -> + Prob is -1.0; + Prob is Temp), + + % Taking elapsed times + statistics(walltime, [_, ElapBddTime]), + BddTime is ElapBddTime/1000. + + + +/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set +and returns an output C set +The C set is a list of triple (N, R, S) where +- N is the index of the head atom used, starting from 0 +- R is the index of the non ground rule used, starting from 1 +- S is the substitution of rule R, in the form of a list whose elements + are of the form 'VarName'=value +*/ +exact(GoalsList, Deriv) :- + exact(GoalsList, [], Deriv). + +exact([], C, C) :- !. + +exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([bagof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([setof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([setof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([\+ H|T], CIn, COut) :- + builtin(H), !, + call((\+ H)), + exact(T, CIn, COut). + +exact([\+ H |T], CIn, COut) :- !, + list2and(HL, H), + findall(D, find_deriv(HL, D), L), + choose_clauses(CIn, L, C1), + exact(T, C1, COut). + +exact([H|T], CIn, COut) :- + builtin(H), !, + call(H), + exact(T, CIn, COut). + +exact([H|T], CIn, COut) :- + def_rule(H, B), + append(B, T, NG), + exact(NG, CIn, COut). + +exact([H|T], CIn, COut) :- + find_rule(H, (R, S, N), B, CIn), + solve_pres(R, S, N, B, T, CIn, COut). + + + +solve_pres(R, S, N, B, T, CIn, COut) :- + member_eq((N, R, S), CIn), !, + append(B, T, NG), + exact(NG, CIn, COut). + +solve_pres(R, S, N, B, T, CIn, COut) :- + append(CIn, [(N, R, S)], C1), + append(B, T, NG), + exact(NG, C1, COut). + + + +/* find_rule(G, (R, S, N), Body, C) + * -------------------------------- + * This predicate takes a goal G and the current C set and returns the index R + * of a disjunctive rule resolving with G together with the index N of the + * resolving head, the substitution S and the Body of the rule. + */ +find_rule(H, (R, S, N), Body, C) :- + rule(H, _P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base b/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base new file mode 100644 index 000000000..a429fc598 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base @@ -0,0 +1,189 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +/* DA MODIFICARE AFFINCHE' USI IL NUOVO CPLINT_INT */ +/* PARTE BDD IN UN FILE SEPARATO? */ + + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* INITIALIZATION + * -------------- + * The following predicate enables the cplint specific features for the program. + */ +:- load_foreign_files(['cplint'], [], init_my_predicates). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, Prob, ResTime, BddTime) + * ---------------------------------------- + * This predicate computes the probability of a given list of goals using an + * exact algorithm. It also returns the number of handled BDDs (trivial but + * present for simmetry with other solving predicates), CPUTime spent in + * performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - Prob: the resulting exact probability for the given list of goals. + * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + % Performing resolution... + findall(Deriv, exact(GoalsList, Deriv), List), + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + % Building and solving equivalent bdds... + build_formula(List, Formula, [], Var), + var2numbers(Var, 0, NewVar), + (setting(save_dot, true) -> + format("Variables: ~p~n", [Var]), + compute_prob(NewVar, Formula, Prob, 1); + compute_prob(NewVar, Formula, Prob, 0)), + + % Taking elapsed times + statistics(walltime, [_, ElapBddTime]), + BddTime is ElapBddTime/1000. + +/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set +and returns an output C set +The C set is a list of triple (N, R, S) where +- N is the index of the head atom used, starting from 0 +- R is the index of the non ground rule used, starting from 1 +- S is the substitution of rule R, in the form of a list whose elements + are of the form 'VarName'=value +*/ +exact(GoalsList, Deriv) :- + exact(GoalsList, [], Deriv). + +exact([], C, C) :- !. + +exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([bagof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([setof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([setof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([\+ H|T], CIn, COut) :- + builtin(H), !, + call((\+ H)), + exact(T, CIn, COut). + +exact([\+ H |T], CIn, COut) :- !, + list2and(HL, H), + findall(D, find_deriv(HL, D), L), + choose_clauses(CIn, L, C1), + exact(T, C1, COut). + +exact([H|T], CIn, COut) :- + builtin(H), !, + call(H), + exact(T, CIn, COut). + +exact([H|T], CIn, COut) :- + def_rule(H, B), + append(B, T, NG), + exact(NG, CIn, COut). + +exact([H|T], CIn, COut) :- + find_rule(H, (R, S, N), B, CIn), + solve_pres(R, S, N, B, T, CIn, COut). + + + +solve_pres(R, S, N, B, T, CIn, COut) :- + member_eq((N, R, S), CIn), !, + append(B, T, NG), + exact(NG, CIn, COut). + +solve_pres(R, S, N, B, T, CIn, COut) :- + append(CIn, [(N, R, S)], C1), + append(B, T, NG), + exact(NG, C1, COut). + + + +/* find_rule(G, (R, S, N), Body, C) + * -------------------------------- + * This predicate takes a goal G and the current C set and returns the index R + * of a disjunctive rule resolving with G together with the index N of the + * resolving head, the substitution S and the Body of the rule. + */ +find_rule(H, (R, S, N), Body, C) :- + rule(H, _P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). diff --git a/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base b/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base new file mode 100644 index 000000000..049780a99 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base @@ -0,0 +1,275 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: montecarlo.pl + * Solves LPADs with Monte Carlo (main predicate: solve(Goals, Prob, Samples, ResTime, BddTime) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ + +:- dynamic rule/4, def_rule/2, randx/1, randy/1, randz/1. + +:- use_module(library(lists)). +:- use_module(library(random)). +:- use_module(library(ugraphs)). +:- use_module(params). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* Starting seed. */ +randx(1). +randy(1). +randz(1). + +/* newsample + * --------- + * This predicate programmatically generates and sets a new seed for the + * algorithm. + */ +newsample :- + retract(randx(X)), + randy(Y), + randz(Z), + (X =< 30269 -> + SuccX is X + 1, + assert(randx(SuccX)); + assert(randx(1)), + retract(randy(_)), + (Y =< 30307 -> + SuccY is Y + 1, + assert(randy(SuccY)); + assert(randy(1)), + retract(randz(_)), + (Z =< 30323 -> + SuccZ is Z + 1, + assert(randz(SuccZ)); + assert(randz(1))))), + setrand(rand(X, Y, Z)). + + +/* solve(Goals, Samples, Time, Lower, Prob, Upper) + * ----------------------------------------------- + * This predicate calls the Monte Carlo solving method for the current problem. + * It requires the Goals to fulfil and returns the number of Samples considered, + * the Time required, the extimated Probability and the Lower and Upper bounds. + * + * INPUT + * - Goals: given list of goals to fulfil. + * + * OUTPUT + * - Samples: number of samples considered to solve the problem. + * - Time: time required to solve the problem. + * - Lower: lower end of the confidence interval. + * - Prob: extimated probability. + * - Upper: upper end of the confidence interval. + */ +solve(Goals, Samples, Time, Lower, Prob, Upper) :- + % Retrieving functional parameters... + setting(k, K), + setting(min_error, MinError), + % Resetting the clocks... + statistics(walltime, [_, _]), + % Performing resolution... + montecarlo(0, 0, Goals, K, MinError, Samples, Lower, Prob, Upper), + % Taking elapsed times... + statistics(walltime, [_, ElapTime]), + % Setting values... + Time is ElapTime/1000. + + + +/* montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) + * --------------------------------------------------------------------------- + * This tail recursive predicate solves the problem currently in memory with a + * Monte Carlo approach. + * It requires the number of samples and successes so far (Count and Success), + * the desired list of Goals to fulfil, the number K of samples to consider at + * once and the threshold MinError for the binomial proportion confidence + * interval. + * It returns the total number of Samples considered, the Lower and Upper ends + * of the the binomial proportion confidence interval and the extimated Prob. + * + * INPUT + * - Count: number of samples considered so far. + * - Success: number of successfull samples considered so far. + * - Goals: list of goals to fulfil. + * - K: number of samples to consider at once. + * - MinError: threshold for the binomial proportion confidence interval. + * + * OUTPUT + * - Samples: total number of samples considered. + * - Lower: lower end of the the binomial proportion confidence interval. + * - Prob: extimated probability. + * - Upper: upper end of the the binomial proportion confidence interval. + * + * NB: This method is based on the binomial proportion confidence interval and + * the Brown's rule of thumb to avoid the case the sample proportion is + * exactly 0.0 or 1.0 and doesn't make use of BDDs. + */ +montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) :- + /* Decomment the following line if you want to test the algorithm with an + incremental seed for each sample. + newsample, + */ + main(Goals, [], _Explan, Valid), + N is Count + 1, + S is Success + Valid, + (N mod K =:= 0 -> +% format("Advancement: ~t~d/~d~30+~n", [S, N]), + P is S / N, + D is N - S, + Semi is 2 * sqrt(P * (1 - P) / N), + Int is 2 * Semi, + /* N * P > 5; N * S / N > 5; S > 5 + * N (1 - P) > 5; N (1 - S / N) > 5; N (N - S) / N > 5; N - S > 5 + */ + ((S > 5, D > 5, (Int < MinError; Int =:= 0)) -> + Samples is N, + Lower is P - Semi, + Prob is P, + Upper is P + Semi; + montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)); + montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)). + + + +/* null + * ---- + * This is dummy predicate to use sparingly when needed. + * Typical uses are as spying predicate during tracing or as dead branch in + * ( -> ; ) predicate. + */ +null. + + + +/* main(Goals, Explan0, Explan1, Valid) + * ------------------------------------ + * This tail recursive predicate looks for a solution to the given Goals + * starting from the given Explan0 and returns the final Explan and 1 (0 otherwise) if it is a + * Valid sample for Montecarlo. + */ +main([], Explan, Explan, 1). + +main([\+ Goal|Tail], Explan0, Explan1, Valid) :- + builtin(Goal), !, + (call((\+ Goal)) -> + main(Tail, Explan0, Explan1, Valid); + Explan1 = Explan0, + Valid = 0). + +main([Goal|Tail], Explan0, Explan1, Valid) :- + builtin(Goal), !, + (call(Goal) -> + main(Tail, Explan0, Explan1, Valid); + Explan1 = Explan0, + Valid = 0). + +main([Goal|Tail], Explan0, Explan1, Valid) :- + findall((IsSample, Goals, Step), explore([Goal|Tail], Explan0, IsSample, Goals, Step), List), + cycle(List, Explan0, Explan1, Valid). + + + +/* explore([Goal|Tail], Explan, Valid, Goals, Step) + * ------------------------------------------------ + * This predicate looks for a Body and the Step to reach it from the given Goal + * and Explan and returns 1 (0 otherwise) if they are a Valid sample for + * Montecarlo. + * Please note that Body and Step are meaningfull only when Valid is 1. + * + * This comment has to be fixed. + */ +explore([Goal|Tail], _Explan, 1, Goals, []) :- + def_rule(Goal, Body), + append(Body, Tail, Goals). + +explore([Goal|Tail], Explan, Valid, Goals, Step) :- + findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)), + append(Body, Tail, Goals), + (member_eq((HeadID, RuleID, Subst), Explan) -> + Step = []; + Step = [(HeadID, RuleID, Subst)]). + + + +/* findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)) + * --------------------------------------------------------------- + * This predicate finds a rule that matches with the given Goal and Explan and + * returns 1 (0 otherwise) if it is a Valid sample for Montecarlo. + * If the sample is Valid, the other return parameters are also meaningfull and + * are the Body and (RuleID, Subst, HeadIS) of the rule that matches with the + * given Goal and Explan. + * + * This comment has to be fixed. + */ +findrule(Goal, Explan, Valid, Body, (HeadId, RuleId, Subst)) :- + rule(Goal, _Prob, Required, RuleId, Subst, _Heads, HeadsList, Body), + sample(HeadsList, HeadId), + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Explan), + (HeadId =:= Required -> + Valid = 1; + Valid = 0). + + + +/* sample(Heads, RuleId, HeadId, Subst) + * ------------------------------------ + * This tail recursive predicate samples a random head among the given Heads of + * the given RuleId and returns its HeadId and Subst. + */ +sample(HeadList, HeadId) :- + random(Prob), + sample(HeadList, 0, 0, Prob, HeadId), !. + +sample([_HeadTerm:HeadProb|Tail], Index, Prev, Prob, HeadId) :- + Succ is Index + 1, + Next is Prev + HeadProb, + (Prob =< Next -> + HeadId = Index; + sample(Tail, Succ, Next, Prob, HeadId)). + + + +/* cycle([(IsSample, Body, [Step])|Tail], Explan0, Explan1, Found) + * ----------------------------------------------------------------- + * This tail recursive predicate analyzes the given Body and Step to reach it + * and returns 0 as it's not a Valid sample for Montecarlo. + * If it is Valid, it looks for a solution to the Body and the given Goals + * starting from the Step and the given Explan and returns 1 if it finds a + * Valid one. + * If it does not find it, it considers the next Body and Step and returns their + * Valid value. + * + * NB: This comment needs to be updated. + */ +cycle([], Explan, Explan, 0). + +cycle([(0, _Goals, Step)|Tail], Explan0, Explan1, IsSample) :- !, + append(Step, Explan0, Explan2), + cycle(Tail, Explan2, Explan1, IsSample). + +cycle([(1, Goals, Step)|Tail], Explan0, Explan1, IsSample) :- + append(Step, Explan0, Explan), + main(Goals, Explan, Explan2, Valid), + (Valid == 1 -> + Explan1 = Explan2, + IsSample = 1; + cycle(Tail, Explan2, Explan1, IsSample)). diff --git a/packages/cplint/approx/.svn/text-base/params.pl.svn-base b/packages/cplint/approx/.svn/text-base/params.pl.svn-base new file mode 100644 index 000000000..d3470e49f --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/params.pl.svn-base @@ -0,0 +1,122 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: params.pl + * Defines and sets parameters needed by other predicates (main: set). + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic setting/2. + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + +/* PARAMETER LIST + * -------------- + * The following list of parameters declares a few constants used along the + * program. + * The default value for each parameter can be changed using the following + * predicate: + * + * set(Parameter, Value). + */ + +/* epsilon_parsing + * --------------- + * This parameter shows the probability's granularity during parsing. + * + * Default value: 0.00001 + * Applies to: parsing + */ +setting(epsilon_parsing, 0.00001). + +/* ground_body + * ----------- + * This parameter tells if both the head and the body of each clause must be + * ground, or else the head only. + * In case the body contains variables not present in the head, it represents + * an existential event. + * + * Default value: false + * Applies to: parsing + */ +setting(ground_body, false). + +/* k + * - + * This parameter shows the amount of items of the same type to consider at once. + * + * Default value: 64 + * Applies to: bestfirst, bestk, montecarlo + */ +setting(k, 64). + +/* min_error + * --------- + * This parameter shows the threshold for the probability interval. + * + * Default value: 0.01 + * Applies to: bestfirst, montecarlo + */ +setting(min_error, 0.01). + +/* prob_bound + * ---------- + * This parameter shows the initial probability bound in a probability bounded + * method. + * + * Default value: 0.01 + * Applies to: deepit + */ +setting(prob_bound, 0.001). + +/* prob_step + * --------- + * This parameter shows the probability deepening step in a probability bounded + * method. + * + * Default value: 0.001 + * Applies to: bestfirst, bestk + */ +setting(prob_step, 0.001). + +/* save_dot + * -------- + * This parameter tells if a .dot file for variables has be created. + * + * Default value: false + * Applies to: bestfirst, bestk, exact + */ +setting(save_dot, false). + +/* timeout + * ------- + * This parameter shows the time to wait before killing a bdd solving process. + * + * Default value: 300 + * Applies to: bestfirst, bestk, exact + */ +setting(timeout, 300). + + + + + +/* PREDICATES + * ---------- + * The predicates in this section interact with the parameters defined above. + */ + +/* set(Parameter, Value) + * --------------------- + * This predicate drops any previously saved value for the given parameter and + * associates it to the new given value. + * + * INPUT + * - Parameter: target parameter for the given new value. + * - Value: new value to assign to the given parameter. + */ +set(Parameter, Value) :- + retract(setting(Parameter, _)), + assert(setting(Parameter, Value)). diff --git a/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base b/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base new file mode 100644 index 000000000..0e32ddaeb --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base @@ -0,0 +1,344 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: parsing.pl + * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +:- use_module(params). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* parse(File) + * ----------- + * This predicate parses the given .cpl file. + * + * Note: it can be called more than once without exiting yap + * + * INPUT + * - File: .cpl file to parse, without extension. + */ +parse(File) :- + atom_concat(File, '.cpl', FileName), + open(FileName, read, FileHandle), + read_clauses(FileHandle, Clauses), + close(FileHandle), + retractall(rule_by_num(_, _, _, _, _)), + retractall(rule(_, _, _, _, _, _, _, _)), + retractall(def_rule(_, _)), + process_clauses(Clauses, 1). + + + + + + + +/* assert_rules() + * -------------- + * This tail recursive predicate parses the given list of (Head:Prob) couples + * and stores them incrementally as rules along with the other parameters. + * + * INPUT + * - Head: current head part. + * - Prob: probability of the current head part. + * - Index: index of the current head part. + * - Subst: substitution for the current head part. + * - Choices: list of current head parts indexes. + * - HeadList: complete head or list of its parts. + * - BodyList: complete body or list of its parts. + */ +assert_rules([], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. % Closing condition. + +assert_rules(['':_Prob], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. + +assert_rules([Head:Prob|Tail], Index, HeadList, BodyList, Choices, Id, Subst) :- + assertz(rule(Head, Prob, Index, Id, Subst, Choices, HeadList, BodyList)), + Next is Index + 1, + assert_rules(Tail, Next, Id, Subst, Choices, HeadList, BodyList). + + + +delete_var(_Var, [], []). + +delete_var(Var, [Current|Tail], [Current|Next]) :- + Var \== Current, !, + delete_var(Var, Tail, Next). + +delete_var(_Var, [_Head|Tail], Tail). + + + +extract_vars(Variable, Var0, Var1) :- + var(Variable), !, + (member_eq(Variable, Var0) -> + Var1 = Var0; + append(Var0, [Variable], Var1)). + +extract_vars(Term, Var0, Var1) :- + Term=..[_F|Args], + extract_vars_list(Args, Var0, Var1). + + + +extract_vars_clause(end_of_file, []). + +extract_vars_clause(Clause, VarNames, Couples) :- + (Clause = (Head :- _Body) -> + true; + Head = Clause), + extract_vars(Head, [], Vars), + pair(VarNames, Vars, Couples). + + + +extract_vars_list([], Var, Var). + +extract_vars_list([Term|Tail], Var0, Var1) :- + extract_vars(Term, Var0, Var), + extract_vars_list(Tail, Var, Var1). + + + +get_var(Var, [Var]) :- + var(Var), !. % Succeeds if Var is currently a free variable, otherwise fails. + +get_var(Var, Value) :- + Var=..[_F|Args], + get_var_list(Args, Value). + + + +get_var_list([], []). + +get_var_list([Head|Tail], [Head|Next]) :- + var(Head), !, + get_var_list(Tail, Next). + +get_var_list([Head|Tail], Vars) :- !, + get_var(Head, Var), + append(Var, Next, Vars), + get_var_list(Tail, Next). + + + +/* ground_prob(HeadList) + * --------------------- + * This tail recursive predicate verifies if the given HeadList is ground. + * + * INPUT + * - HeadList: list of heads to verify its groundness. + */ +ground_prob([]). + +ground_prob([_Head:ProbHead|Tail]) :- + ground(ProbHead), % Succeeds if there are no free variables in the term ProbHead. + ground_prob(Tail). + + + +pair(_VarName, [], []). + +pair([VarName = _Var|TailVarName], [Var|TailVar], [VarName = Var|Tail]) :- + pair(TailVarName, TailVar, Tail). + + + +/* process_head(HeadList, CompleteHeadList) + * ---------------------------------------- + * Note: if the annotation in the head are not ground, the null atom is not + * added and the eventual formulas are not evaluated. + */ +process_head(HeadList, GroundHeadList) :- + ground_prob(HeadList), !, + process_head_ground(HeadList, 0, GroundHeadList); + +process_head(HeadList, HeadList). + + + +/* process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) + * ---------------------------------------------------------------- + */ +process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) :- + ProbLast is 1 - Prob - ProbHead, + setting(epsilon_parsing, Eps), + EpsNeg is - Eps, + ProbLast > EpsNeg, + (ProbLast > Eps -> + Null = ['':ProbLast]; + Null = []). + +process_head_ground([Head:ProbHead|Tail], Prob, [Head:ProbHead|Next]) :- + ProbNext is Prob + ProbHead, + process_head_ground(Tail, ProbNext, Next). + + + + + + + + + + + + + + + + + +/* process_body(BodyList, Vars0, Vars1) + * ------------------------------------ + * Note: setof must have a goal in the form B^G, where B is a term containing + * the existential variables. + */ +process_body([], Vars, Vars). + +process_body([setof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + get_var(B, VarsB), + remove_vars(VarsA, Vars0, Vars3), + remove_vars(VarsB, Vars3, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([setof(A, _G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + remove_vars(VarsA, Vars0, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([bagof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + get_var(B, VarsB), + remove_vars(VarsA, Vars0, Vars3), + remove_vars(VarsB, Vars3, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([bagof(A, _G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + remove_vars(VarsA, Vars0, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([_Head|Tail], Vars0, Vars1) :- !, + process_body(Tail, Vars0, Vars1). + + + + + + + +process_clauses([(end_of_file, [])], _Id). + +/* NB: il seguente predicato è stato commentato perchè usa predicati non conformi + * a quelli attesi (vedi 'rule\5'). + * / +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head=uniform(A, P, L), !, + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + remove_vars([P], BodyListValue, V2), + append(BodyList, [length(L, Tot), nth0(Number, L, P)], BL1), + append(V2, ['Tot'=Tot], V3), + assertz(rule(Id, V3, _NH, uniform(A:1/Tot, L, Number), BL1)), + assertz(rule_uniform(A, Id, V3, _NH, 1/Tot, L, Number, BL1)), + N1 is Id+1, + process_clauses(Tail, N1). */ + +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head = (_;_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), + assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head = (_:_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), + assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([((Head :- Body), _V)|Tail], Id) :- !, + list2and(BodyList, Body), + assert(def_rule(Head, BodyList)), + process_clauses(Tail, Id). + +process_clauses([(Head, Value)|Tail], Id) :- + Head=(_;_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), + assertz(rule_by_num(Id, Value, NH, HeadList, [])), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([(Head, Value)|Tail], Id) :- + Head=(_:_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), + assertz(rule_by_num(Id, Value, NH, HeadList, [])), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([(Head, _V)|Tail], Id) :- + assert(def_rule(Head, [])), + process_clauses(Tail, Id). + + + +read_clauses(Stream, Clauses) :- + (setting(ground_body, true) -> + read_clauses_ground_body(Stream, Clauses); + read_clauses_exist_body(Stream, Clauses)). + + + +read_clauses_exist_body(Stream, [(Clause, Vars)|Next]) :- + read_term(Stream, Clause, [variable_names(VarNames)]), + extract_vars_clause(Clause, VarNames, Vars), + (Clause = end_of_file -> + Next = []; + read_clauses_exist_body(Stream, Next)). + + + +read_clauses_ground_body(Stream, [(Clause, Vars)|Next]) :- + read_term(Stream, Clause, [variable_names(Vars)]), + (Clause = end_of_file -> + Next = []; + read_clauses_ground_body(Stream, Next)). + + + +remove_vars([], Vars, Vars). + +remove_vars([Head|Tail], Vars0, Vars1) :- + delete_var(Head, Vars0, Vars2), + remove_vars(Tail, Vars2, Vars1). diff --git a/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base b/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base new file mode 100644 index 000000000..d0e724167 --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base @@ -0,0 +1,727 @@ +%%% -*- Mode: Prolog; -*- +:-source. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% prefix-trees for managing a DNF +% remembers shortest prefix of a conjunction only (i.e. a*b+a*b*c results in a*b only, but b*a+a*b*c is not reduced) +% children are sorted, but branches aren't (to speed up search while keeping structure sharing from proof procedure) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +:- module(ptree,[init_ptree/1, + delete_ptree/1, + rename_ptree/2, + member_ptree/2, + enum_member_ptree/2, + insert_ptree/2, + delete_ptree/2, + edges_ptree/2, + count_ptree/2, + prune_check_ptree/2, + empty_ptree/1, + merge_ptree/3, + bdd_ptree/3, + bdd_ptree_map/4 + ]). +:-source. +:- use_module(library(tries), + [ + trie_open/1, + trie_close/1, + trie_stats/4, + trie_check_entry/3, + trie_get_entry/2, + trie_put_entry/3, + trie_remove_entry/1, + trie_usage/4, + trie_dup/2, + trie_join/2, + trie_traverse/2 + ]). + +:- use_module(library(ordsets), + [ + ord_subset/2 + ]). + +:- style_check(all). +%:- yap_flag(unknown,error). + +%:- use_module(flags,[problog_flag/2]). +:- ensure_loaded(library(lists)). +:- ensure_loaded(library(system)). + +% name lexicon external - internal +sym(1,tree1) :- !. +sym(2,tree2) :- !. +sym(3,tree3) :- !. +sym(N,AN) :- atomic_concat([tree,N],AN). + +%%%%%%%%%%%%%%%%%%%%%%%% +% ptree basics +%%%%%%%%%%%%%%%%%%%%%%%% + +init_ptree(ID) :- + sym(ID,Sym), + trie_open(Trie), + nb_setval(Sym, Trie). + +delete_ptree(ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), !, + trie_close(Trie), + trie_open(NewTrie), + nb_setval(Sym, NewTrie). +delete_ptree(_). + +rename_ptree(OldID,NewID) :- + sym(OldID,OldSym), + sym(NewID,NewSym), + nb_getval(OldSym, Trie), + nb_set_shared_val(NewSym, Trie). + +empty_ptree(ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_usage(Trie, 0, 0, 0). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% member +%%%%%%%%%%%%%%%%%%%%%%%% + +% non-backtrackable (to check) +member_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, List, _). + +% backtrackable (to list) +enum_member_ptree(ID,List) :- + sym(ID,Sym), + nb_getval(Sym, Tree), + trie_path(Tree, List). + +trie_path(Tree, List) :- + trie_traverse(Tree,Ref), + trie_get_entry(Ref, List). + +%%%%%%%%%%%%%%%%%%%%%%%% +% insert conjunction +%%%%%%%%%%%%%%%%%%%%%%%% +insert_ptree(true,ID) :- + sym(ID,Sym), + !, + nb_getval(Sym, Trie), + trie_close(Trie), + trie_open(NTrie), + trie_put_entry(NTrie, true, _). +insert_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_put_entry(Trie, List, _). + +%%%%%%%%%%%%%%%%%%%%%%%% +% delete conjunction +%%%%%%%%%%%%%%%%%%%%%%%% +delete_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, List, Ref), + trie_remove_entry(Ref). + + +%%%%%%%% +% return list -Edges of all edge labels in ptree +% doesn't use any heuristic to order those for the BDD +% (automatic reordering has to do the job) +%%%%%%%%% +edges_ptree(ID,[]) :- + empty_ptree(ID), + !. +edges_ptree(ID,[]) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, true, _), + !. +edges_ptree(ID,Edges) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + %( + setof(X, trie_literal(Trie, X), Edges).%-> + /* true + ; + Edges=[] + ).*/ + +trie_literal(Trie, X) :- + trie_traverse(Trie,Ref), + trie_get_entry(Ref, List), + member(X, List). + +%%%%%%%% +% number of conjunctions in the tree +%%%%%%%%% + +count_ptree(ID,N) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_usage(Trie, N, _, _). + +%%%%%%%% +% check whether some branch of ptree is a subset of conjunction List +% useful for pruning the search for proofs (optional due to time overhead) +% currently not implemented, just fails +%%%%%%% + +prune_check_ptree(_List,_TreeID) :- + format(user,'FAIL: prune check currently not supported~n',[]), + flush_output(user), + fail. + +%%%%%%%%%%%%% +% merge two ptrees +% - take care not to loose proper prefixes that are proofs! +%%%%%%%%%%%%%%% + +merge_ptree(ID1,_,ID3) :- + sym(ID1,Sym1), + sym(ID3,Sym3), + nb_getval(Sym1, T1), + trie_check_entry(T1, true, _), + !, + trie_open(T3), + trie_put_entry(T3, true, _), + nb_setval(Sym3, T3). +merge_ptree(_,ID2,ID3) :- + sym(ID2,Sym2), + sym(ID3,Sym3), + nb_getval(Sym2, T2), + trie_check_entry(T2, true, _), + !, + trie_open(T3), + trie_put_entry(T3, true, _), + nb_setval(Sym3, T3). +merge_ptree(ID1,ID2,ID3) :- + sym(ID1,Sym1), + sym(ID2,Sym2), + sym(ID3,Sym3), + nb_getval(Sym1, T1), + nb_getval(Sym2, T2), + trie_dup(T1, T3), + trie_join(T3,T2), + nb_setval(Sym3, T3). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% write BDD info for given ptree to file +% - initializes leaf BDDs (=variables) first +% - then compresses ptree to exploit subtree sharing +% - bdd_pt/1 does the work on the structure itself +%%%%%%%%%%%%%%%%%%%%%%%% + +bdd_ptree(ID,FileBDD,FileParam) :- + bdd_ptree_script(ID,FileBDD,FileParam), + eraseall(map), + eraseall(vars). + +% version returning variable mapping +bdd_ptree_map(ID,FileBDD,FileParam,FileMapping) :- + bdd_ptree_script(ID,FileBDD,FileParam), + findall(X,recorded(map,X,_),Map), + add_probs(Map,Mapping), + tell(FileMapping), + write(Mapping),write('.'), + told, + eraseall(map), + eraseall(vars). + +add_probs([],[]). +add_probs([m(R,S,Num,Name)|Map],[m(R,S,Num,Name,Prob)|Mapping]) :- + user:rule_by_num(R,S,_N,Head,_Body), + user:get_probs(Head,Prob), + add_probs(Map,Mapping). + +% number of variables may be to high: +% counted on trie, but conversion to old tree representation +% transforms A*B+A to A (prefix-test) +bdd_ptree_script(ID,FileBDD,FileParam) :- + assert(v_num(0)), + edges_ptree(ID,Edges), + compute_nvars(Edges,0,NVars,0,NBVars), + tell(FileParam), + bdd_vars_script(Edges), + + flush_output, + + told, + length(Edges,_VarCount), + assert(c_num(1)), + bdd_pt(ID,CT),!, + c_num(NN), + IntermediateSteps is NN-1, + tell(FileBDD), + format('@BDD1~n~w~n~w~n~w~n~w~n',[NVars,NBVars,0,IntermediateSteps]), + output_compressed_script_only(CT),!, + + told, + retractall(c_num(_)), + retractall(v_num(_)), + retractall(compression(_,_)). + +compute_nvars([],NV,NV,NBV,NBV). + +compute_nvars([(_V,R,S)|T],NV0,NV1,NBV0,NBV1):- + (recorded(vars,v(R,S),_)-> + compute_nvars(T,NV0,NV1,NBV0,NBV1) + ; + recorda(vars,v(R,S),_), + NV2 is NV0+1, + user:rule_by_num(R,S,_N,Head,_Body), + length(Head,L), + NBV2 is NBV0+integer(ceiling(log(L)/log(2))), + compute_nvars(T,NV2,NV1,NBV2,NBV1) + ). + +% write parameter file by iterating over all var/not(var) occuring in the tree +/*bdd_vars_script(Edges) :- + bdd_vars_script(Edges,0). +*/ +bdd_vars_script([]). +%%%% Bernd, changes for negated ground facts +/* +bdd_vars_script([(_V,R,S)|B],N) :- + recorded(map,m(R,S,_Num,_NameA),_),!, + bdd_vars_script(B,N). +*/ +bdd_vars_script([(_V,R,S)|B]) :- + (recorded(map,m(R,S,_Number,_NameA),_)-> + true + ; + user:rule_by_num(R,S,_N,Head,_Body), + user:get_probs(Head,P), + get_var_name(R,S,_Number,NameA), + length(Head,NV), + format('@~w~n~d~n',[NameA,NV]), + print_probs(P) + ), + bdd_vars_script(B). + +print_probs([H]):-!, + format("~f~n",[H]). + +print_probs([H|T]):- + format("~f ",[H]), + print_probs(T). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% find top level symbol for script +%%%%%%%%%%%%%%%%%%%%%%%% + +% special cases: variable-free formulae +bdd_pt(ID,false) :- + empty_ptree(ID), + !, + once(retractall(c_num(_))), + once(assert(c_num(2))). +bdd_pt(ID,true) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, true, _), + !, + once(retractall(c_num(_))), + once(assert(c_num(2))). + +% general case: transform trie to nested tree structure for compression +bdd_pt(ID,CT) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_to_tree(Trie, Tree), + compress_pt(Tree,CT). + +trie_to_tree(Trie, Tree) :- + findall(Path,trie_path(Trie, Path), Paths), + add_trees(Paths, [], Tree). + +add_trees([], Tree, Tree). +add_trees([List|Paths], Tree0, Tree) :- + ins_pt(List, Tree0, TreeI), + add_trees(Paths, TreeI, Tree). + +ins_pt([],_T,[]) :- !. +ins_pt([A|B],[s(A1,AT)|OldT],NewT) :- + compare(Comp, A1, A), + (Comp == = -> + (AT == [] -> + NewT=[s(A1,AT)|OldT] + ; + NewT = [s(A1,NewAT)|OldT], + ins_pt(B, AT, NewAT)) + ; + Comp == > -> + NewT = [s(A1,AT)|Tree], + ins_pt([A|B], OldT, Tree) + ; + NewT = [s(A,BTree),s(A1,AT)|OldT], + ins_pt(B,[],BTree) + ). +ins_pt([A|B],[],[s(A,NewAT)]) :- + ins_pt(B,[],NewAT). + +%%%%%%%%%%%% +% BDD compression: alternates and- and or-levels to build BDD bottom-up +% each sub-BDD will be either a conjunction of a one-node BDD with some BDD or a disjunction of BDDs +% uses the internal database to temporarily store a map of components +%%%%%%%%%%%% + +% T is completely compressed and contains single variable +% i.e. T of form x12 or ~x34 +compress_pt(T,TT) :- + atom(T), + test_var_name(T), + !, + get_next_name(TT), + assertz(compression(TT,[T])). +% T is completely compressed and contains subtrees +% i.e. T of form 'L56' +compress_pt(T,T) :- + atom(T). +% T not yet compressed +% i.e. T is a tree-term (nested list & s/2 structure) +% -> execute one layer of compression, then check again +compress_pt(T,CT) :- + \+ atom(T), + and_or_compression(T,IT), + compress_pt(IT,CT). + +% transform tree-term T into tree-term CT where last two layers have been processed +% i.e. introduce names for subparts (-> Map) and replace (all occurrenes of) subparts by this names +and_or_compression(T,CT) :- + and_comp(T,AT), + or_comp(AT,CT). + +% replace leaves that are single child by variable representing father-AND-child +and_comp(T,AT) :- + all_leaves_pt(T,Leaves), + compression_mapping(Leaves,Map), + replace_pt(T,Map,AT). + +% replace list of siblings by variable representing their disjunction +or_comp(T,AT) :- + all_leaflists_pt(T,Leaves), + compression_mapping(Leaves,Map), + replace_pt(T,Map,AT). + +all_leaves_pt(T,L) :- + all(X,some_leaf_pt(T,X),L). + +some_leaf_pt([s(A,[])|_],s(A,[])). +some_leaf_pt([s(A,L)|_],s(A,L)) :- + not_or_atom(L). +some_leaf_pt([s(_,L)|_],X) :- + some_leaf_pt(L,X). +some_leaf_pt([_|L],X) :- + some_leaf_pt(L,X). + +all_leaflists_pt(L,[L]) :- + atomlist(L),!. +all_leaflists_pt(T,L) :- + all(X,some_leaflist_pt(T,X),L),!. +all_leaflists_pt(_,[]). + +some_leaflist_pt([s(_,L)|_],L) :- + atomlist(L). +some_leaflist_pt([s(_,L)|_],X) :- + some_leaflist_pt(L,X). +some_leaflist_pt([_|L],X) :- + some_leaflist_pt(L,X). + +not_or_atom(T) :- + ( + T=not(T0) + -> + atom(T0); + atom(T) + ). + +atomlist([]). +atomlist([A|B]) :- + not_or_atom(A), + atomlist(B). + +% for each subtree that will be compressed, add its name +% only introduce 'L'-based names when subtree composes elements, store these in compression/2 for printing the script +compression_mapping([],[]). +compression_mapping([First|B],[N-First|BB]) :- + ( + First = s((V,R,S),[]) % subtree is literal -> use variable's name x17 from map (add ~ for negative case) + -> + recorded(map,m(R,S,_Num,Tmp),_), %check + atomic_concat([Tmp,'-',V],N) + ; + (First = s(A,L),not_or_atom(L)) % subtree is node with single completely reduced child -> use next 'L'-based name + -> (get_next_name(N), + assertz(compression(N,s(A,L)))) + ; + (First = [L],not_or_atom(L)) % subtree is an OR with a single completely reduced element -> use element's name + -> N=L + /*, + recorded(refc,m(L,RefC),Ref), + erase(Ref), + RefC1 is RefC+1, + recorda(refc,m(L,RefC1),_)*/ + ; + (atomlist(First), % subtree is an OR with only (>1) completely reduced elements -> use next 'L'-based name + get_next_name(N), + assertz(compression(N,First))) + ), + compression_mapping(B,BB). + +increase_counts([]). + +increase_counts([H|T]):- + recorded(refc,m(H,RC),Ref), + erase(Ref), + RC1 is RC+1, + recorda(refc,m(H,RC1),_), + increase_counts(T). + +compute_or([A],Node0,Node1):- + recorded(mapnodes,m(A,Node),_), + or(Node0,Node,Node1). + +compute_or([A,B|T],Node0,Node1):- + recorded(mapnodes,m(A,Node),_), + or(Node0,Node,Node2), + compute_or([B|T],Node2,Node1). + + +% replace_pt(+T,+Map,-NT) +% given the tree-term T and the Map of Name-Subtree entries, replace each occurence of Subtree in T with Name -> result NT +replace_pt(T,[],T). +replace_pt([],_,[]). +replace_pt(L,M,R) :- + atomlist(L), + member(R-L,M), + !. +replace_pt([L|LL],[M|MM],R) :- + replace_pt_list([L|LL],[M|MM],R). + +replace_pt_list([T|Tree],[M|Map],[C|Compr]) :- + replace_pt_single(T,[M|Map],C), + replace_pt_list(Tree,[M|Map],Compr). +replace_pt_list([],_,[]). + +replace_pt_single(s(A,T),[M|Map],Res) :- + atomlist(T), + member(Res-s(A,T),[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],s(A,Res)) :- + atomlist(T), + member(Res-T,[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],Res) :- + member(Res-s(A,T),[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],s(A,TT)) :- + replace_pt_list(T,[M|Map],TT). +replace_pt_single(A,_,A) :- + not_or_atom(A). + +output_compressed_script_only(false) :- + !, + format('L1 = FALSE~nL1~n',[]). +output_compressed_script_only(true) :- + !, + format('L1 = TRUE~nL1~n',[]). +output_compressed_script_only(T) :- + once(retract(compression(Short,Long))), + assertz(compression(Short,Long)), + (T = Short -> + format('~w = ',[Short]), + format_compression_script_only(Long), + format('~w~n',[Short]) + ; + format('~w = ',[Short]), + format_compression_script_only(Long), + output_compressed_script_only(T) + ). + +format_compression_script_only(s((V,R,S),B0)) :- + recorded(map,m(R,S,_Num,C),_), + atomic_concat([C,'-',V],C1), + format('~w * ~w~n',[C1,B0]). + +format_compression_script_only([A]) :- + format('~w~n',[A]). +format_compression_script_only([A,B|C]) :- + format('~w + ',[A]), + format_compression_script_only([B|C]). + + +%%%%%%%%%%%% +% output for script +% input argument is compressed tree, i.e. true/false or name assigned in last compression step +%%%%%%%%%%%% +output_compressed_script(false) :- + !. + %format('L1 = FALSE~nL1~n',[]). +output_compressed_script(true) :- + !. + %format('L1 = TRUE~nL1~n',[]). +% for each name-subtree pair, write corresponding line to script, e.g. L17 = x4 * L16 +% stop after writing definition of root (last entry in compression/2), add it's name to mark end of script +output_compressed_script(T) :- + once(retract(compression(Short,Long))), + (T = Short -> + % format('~w = ',[Short]), + format_compression_script(Long,Short) + % format('~w~n',[Short]) + ; + % format('~w = ',[Short]), + format_compression_script(Long,Short), + output_compressed_script(T)). + +format_compression_script(s((V,R,S),B0),Short) :-!, + % checkme + recorded(map,m(R,S,_Num,C),_), + atomic_concat([C,'-',V],C1), + recorded(mapnodes,m(C1,Node1),_), + recorded(mapnodes,m(B0,Node2),_), + % format('~w * ~w~n',[C1,B0]), + and(Node1,Node2,Node), + recorda(mapnodes,m(Short,Node),_), + recorded(refc,m(C1,RefC1),Ref1), + recorded(refc,m(B0,RefC2),Ref2), + erase(Ref1), + erase(Ref2), + RefC11 is RefC1-1, + RefC21 is RefC2-1, + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(C1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(B0,RefC21),_) + ). + +format_compression_script([H1],Short):-!, + % format('~w~n',[A]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + recorda(mapnodes,m(Short,Node1),_). + +format_compression_script([H1,H2],Short):-!, + % format('~w + ~w~n',[H1,H2]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + recorded(mapnodes,m(H2,Node2),_), + recorded(refc,m(H2,RefC2),Ref2), + erase(Ref2), + RefC21 is RefC2-1, + or(Node1,Node2,Node), + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(H2,RefC21),_) + ), + recorda(mapnodes,m(Short,Node),_). + +format_compression_script([H1,H2,H3|T],Short):- + %format('~w + ~w +',[H1,H2]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + recorded(mapnodes,m(H2,Node2),_), + recorded(refc,m(H2,RefC2),Ref2), + erase(Ref2), + RefC21 is RefC2-1, + or(Node1,Node2,Node), + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(H2,RefC21),_) + ), + format_compression_script1([H3|T],Node,Short). + +format_compression_script1([A],Node1,Short) :-!, +% format('~w~n',[A]), + recorded(mapnodes,m(A,Node2),_), + recorded(refc,m(A,RefC),Ref), + erase(Ref), + or(Node1,Node2,Node), + deref(Node1), + recorda(mapnodes,m(Short,Node),_), + RefC1 is RefC-1, + (RefC1=:=0-> + deref(Node2) + ; + recorda(refc,m(A,RefC1),_) + ). + +format_compression_script1([A,B|C],Node1,Short) :- + format('~w + ',[A]), + recorded(mapnodes,m(A,Node2),_), + recorded(refc,m(A,RefC),Ref), + erase(Ref), + or(Node1,Node2,Node), + deref(Node1), + RefC1 is RefC-1, + (RefC1=:=0-> + deref(Node2) + ; + recorda(refc,m(A,RefC1),_) + ), + format_compression_script1([B|C],Node,Short). + +%%%%%%%%%%%%%%%%%%%%%%%% +% auxiliaries for translation to BDD +%%%%%%%%%%%%%%%%%%%%%%%% + +% prefix the current counter with "L" +get_next_name(Name) :- + retract(c_num(N)), + NN is N+1, + assert(c_num(NN)), + atomic_concat('L',N,Name). + +get_next_var_id(N,Name) :- + retract(v_num(N)), + NN is N+1, + assert(v_num(NN)), + atomic_concat('x',N,Name). + +% create BDD-var as fact id prefixed by x +% learning.yap relies on this format! +% when changing, also adapt test_var_name/1 below +get_var_name(R,S,Number,NameA) :- + get_next_var_id(Number,NameA), + recorda(map,m(R,S,Number,NameA),_). + +% test used by base case of compression mapping to detect single-variable tree +% has to match above naming scheme +test_var_name(T) :- + atomic_concat(x,_,T). diff --git a/packages/cplint/approx/.svn/text-base/utility.pl.svn-base b/packages/cplint/approx/.svn/text-base/utility.pl.svn-base new file mode 100644 index 000000000..3079235fe --- /dev/null +++ b/packages/cplint/approx/.svn/text-base/utility.pl.svn-base @@ -0,0 +1,367 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: parsing.pl + * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* BUILTIN PREDICATES + * ------------------ + * This section declares the builtin predicates. + */ +builtin(_A is _B). +builtin(_A > _B). +builtin(_A < _B). +builtin(_A >= _B). +builtin(_A =< _B). +builtin(_A =:= _B). +builtin(_A =\= _B). +builtin(true). +builtin(false). +builtin(_A = _B). +builtin(_A==_B). +builtin(_A\=_B). +builtin(_A\==_B). +builtin(length(_L, _N)). +builtin(member(_El, _L)). +builtin(average(_L, _Av)). +builtin(max_list(_L, _Max)). +builtin(min_list(_L, _Max)). +builtin(nth0(_, _, _)). +builtin(nth(_, _, _)). +builtin(eraseall(_Id)). +builtin(recordz(_Id, _Item, _)). +builtin(recordzifnot(_Id, _Item, _)). + + + +member_eq(Item, [Head|_Tail]) :- + Item==Head, !. + +member_eq(Item, [_Head|Tail]) :- + member_eq(Item, Tail). + + + +not_already_present_with_a_different_head(_HeadId, _RuleId, _Subst, []). + +not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(HeadId1, RuleId, Subst1)|Tail]) :- + not_different(HeadId, HeadId1, Subst, Subst1), !, + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). + +not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(_HeadId1, RuleId1, _Subst1)|Tail]) :- + RuleId \== RuleId1, + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). + + + +not_different(_HeadId, _HeadId1, Subst, Subst1) :- + Subst \= Subst1, !. + +not_different(HeadId, HeadId1, Subst, Subst1) :- + HeadId \= HeadId1, !, + dif(Subst, Subst1). + +not_different(HeadId, HeadId, Subst, Subst). + + + +get_groundc([], [], [], P, P) :- !. + +get_groundc([H|T], [H|T1], TV, P0, P1) :- + ground(H), !, + H=(N, R, S), + rule_by_num(R, S, _N, Head, _Body), + nth0(N, Head, (_A:P)), + P2 is P0*P, + get_groundc(T, T1, TV, P2, P1). + +get_groundc([H|T], T1, [H|TV], P0, P1) :- + get_groundc(T, T1, TV, P0, P1). + +get_prob([], P, P) :- !. + +get_prob([H|T], P0, P1) :- + H=(N, R, S), + rule_by_num(R, S, _N, Head, _Body), + nth0(N, Head, (_A:P)), + P2 is P0*P, + get_prob(T, P2, P1). + + + + +find_rulec(H, (R, S, N), Body, C, P) :- + rule(H, P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). + + + +/* var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) + * ---------------------------------------------------------------------------------- + * This tail recursive predicate converts a list of couples (Rule, Subst) into a + * list of triples (Index, Count, Probs). + * Rule and Subst are the index of their equivalent rule and substitution. + * Index is a progressive identifier starting from 0. + * Count is the number of head atoms and Probs is the vector of their + * probabilities. + * + * INPUT + * - Couples: list of couples to convert. + * + * OUTPUT + * - Triples: list of equivalent triples. + */ +var2numbers([], _N, []). + +var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) :- + find_probs(Rule, Subst, Probs), + length(Probs, Heads), + Next is Index+1, + var2numbers(CoupleTail, Next, TripleTail). + + + +/* build_formula(ListC, Formula, VarIn, VarOut) + * -------------------------------------------- + * This predicate parses a given list of C sets with a given list of variables + * and returns the equivalent formula with its list of variables. + * + * Note: each Formula is expressed in the form: [Term1, ..., TermN], where each + * term is expressed in the form: [Factor1, ..., FactorM], where each + * factor is hence expressed in the form: (Var, Name). + * Finally, Var is the index of the multivalued variable Var, and Value is + * the index of its value. + * + * INPUT + * - ListC: given list of C sets. + * - VarIn: list of variables pertaining to ListC. + * + * OUTPUT + * - Formula: the formula equivalent to ListC. + * - VarOut: list of variables pertaining to Formula. + */ +build_formula([], [], Var, Var, Count, Count). +%% Closing condition: stop if no more terms (current Var is final Var, current Count is final Count) + +build_formula([D|TD], [F|TF], VarIn, VarOut, C0, C1) :- + length(D, NC), + C2 is C0+NC, + reverse(D, D1), + build_term(D1, F, VarIn, Var1), + build_formula(TD, TF, Var1, VarOut, C2, C1). + %% Recursive call: procedd to next terms, building rest of formula and handling vars and count. + +build_formula([], [], Var, Var). + +build_formula([D|TD], [F|TF], VarIn, VarOut) :- + build_term(D, F, VarIn, Var1), + build_formula(TD, TF, Var1, VarOut). + + + +build_term([], [], Var, Var). + +build_term([(_, pruned, _)|TC], TF, VarIn, VarOut) :- !, + build_term(TC, TF, VarIn, VarOut). + +build_term([(N, R, S)|TC], [[NVar, N]|TF], VarIn, VarOut) :- + (nth0_eq(0, NVar, VarIn, (R, S)) -> + Var1=VarIn; + append(VarIn, [(R, S)], Var1), + length(VarIn, NVar)), + build_term(TC, TF, Var1, VarOut). + + + +find_probs(R, S, Probs) :- + rule_by_num(R, S, _N, Head, _Body), + get_probs(Head, Probs). + + + +get_probs(uniform(_A:1/Num, _P, _Number), ListP) :- + Prob is 1/Num, + list_el(Num, Prob, ListP). + +get_probs([], []). + +get_probs([_H:P|T], [P1|T1]) :- + P1 is P, + get_probs(T, T1). + + + +list_el(0, _P, []) :- !. + +list_el(N, P, [P|T]) :- + N1 is N-1, + list_el(N1, P, T). + + + +/* nth0_eq(PosIn, PosOut, List, Elem) + * ---------------------------------- + * This predicate searches for an element that matches with the given one in the + * given list, starting from the given position, and returns its position. + * + * INPUT + * - PosIn: initial position. + * - List: list to parse. + * - Elem: element to match. + * + * OUTPUT + * - PosOut: next position of a matching element. + */ +nth0_eq(N, N, [H|_T], Elem) :- + H==Elem, !. + +nth0_eq(NIn, NOut, [_H|T], Elem) :- + N1 is NIn+1, + nth0_eq(N1, NOut, T, Elem). + + + +list2and([X], X) :- + X\=(_, _), !. + +list2and([H|T], (H, Ta)) :- !, + list2and(T, Ta). + + + +list2or([X], X) :- + X\=;(_, _), !. + +list2or([H|T], (H ; Ta)) :- !, + list2or(T, Ta). + + + +choose_clausesc(_G, C, [], C). + +choose_clausesc(CG0, CIn, [D|T], COut) :- + member((N, R, S), D), + choose_clauses_present(N, R, S, CG0, CIn, COut, T). + +choose_clausesc(G0, CIn, [D|T], COut) :- + member((N, R, S), D), + new_head(N, R, S, N1), + \+ already_present(N1, R, S, CIn), + \+ already_present(N1, R, S, G0), + impose_dif_cons(R, S, CIn), + choose_clausesc(G0, [(N1, R, S)|CIn], T, COut). + + + +choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- + already_present_with_a_different_head_ground(N, R, S, CG0), !, + choose_clausesc(CG0, CIn, T, COut). + +choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- + already_present_with_a_different_head(N, R, S, CIn), + choose_a_head(N, R, S, CIn, C1), + choose_clausesc(CG0, C1, T, COut). + + + +/* new_head(N, R, S, N1) + * --------------------- + * This predicate selects an head for rule R different from N with substitution + * S and returns it in N1. + */ +new_head(N, R, S, N1) :- + rule_by_num(R, S, Numbers, Head, _Body), + Head\=uniform(_, _, _), !, + nth0(N, Numbers, _Elem, Rest), + member(N1, Rest). + +new_head(N, R, S, N1) :- + rule_uniform(_A, R, S, Numbers, 1/Tot, _L, _Number, _Body), + listN(0, Tot, Numbers), + nth0(N, Numbers, _Elem, Rest), + member(N1, Rest). + + + +/* already_present(N, R, S, [(N, R, SH)|_T]) + * ----------------------------------------- + * This predicate checks if a rule R with head N and selection S (or one of its + * generalizations is in C) is already present in C. + */ +already_present(N, R, S, [(N, R, SH)|_T]) :- + S=SH. + +already_present(N, R, S, [_H|T]) :- + already_present(N, R, S, T). + + + +already_present_with_a_different_head(N, R, S, [(NH, R, SH)|_T]) :- + \+ \+ S=SH, NH \= N. + +already_present_with_a_different_head(N, R, S, [_H|T]) :- + already_present_with_a_different_head(N, R, S, T). + +already_present_with_a_different_head_ground(N, R, S, [(NH, R, SH)|_T]) :- + S=SH, NH \= N. + +already_present_with_a_different_head_ground(N, R, S, [_H|T]) :- + already_present_with_a_different_head_ground(N, R, S, T). + + + +impose_dif_cons(_R, _S, []) :- !. + +impose_dif_cons(R, S, [(_NH, R, SH)|T]) :- !, + dif(S, SH), + impose_dif_cons(R, S, T). + +impose_dif_cons(R, S, [_H|T]) :- + impose_dif_cons(R, S, T). + + + +/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) + * -------------------------------------------------------- + * This predicate chooses and returns an head. + * It instantiates a more general rule if it is contained in C with a different + * head. + */ +choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) :- + S=SH, + dif(N, NH). + +/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) + * -------------------------------------------------------------------- + * This predicate chooses and returns an head. + * It instantiates a more general rule if it is contained in C with a different + * head. + * It ensures the same ground clause is not generated again. + */ +choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) :- + \+ \+ S=SH, S\==SH, + dif(N, NH), + dif(S, SH). + +choose_a_head(N, R, S, [H|T], [H|T1]) :- + choose_a_head(N, R, S, T, T1). + + + +listN(N, N, []) :- !. + +listN(NIn, N, [NIn|T]) :- + N1 is NIn+1, + listN(N1, N, T). + + diff --git a/packages/cplint/approx/bestfirst.pl b/packages/cplint/approx/bestfirst.pl new file mode 100644 index 000000000..8f5cf20ee --- /dev/null +++ b/packages/cplint/approx/bestfirst.pl @@ -0,0 +1,451 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) + * ------------------------------------------------------ + * This predicate computes the probability of a given list of goals using an + * iterative deepening, probability bounded algorithm. + * It also returns the number of handled BDDs and the CPUTime spent performing + * resolution and spent handling the BDDs. + * + * Note: when their derivation is cut, negative goals are added to the head of + * the goals' list to be solved during the following iteration. + * + * INPUT + * - GoalsList: given list of goal to work on. It can contains variables: the + * predicate returns in backtracking all the solutions and their equivalent + * lower and upper bound probability. + * + * OUTPUT + * - ProbLow: resulting lower bound probability for the given list of goals. + * - ProbUp: resulting upper bound probability for the given list of goals. + * - Count: number of BDDs generated by the algorithm. + * - ResTime: CPU time spent on performing resolution. + * - BddTime: CPU time spent on handling BDDs. + */ +solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) :- + setting(k, K), + setting(min_error, MinError), + setting(prob_step, ProbStep), + + ProbStepLog is log(ProbStep), + + assert(low(0, 0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + bestfirst([0.0-([], [], Goals)], 0, K, MinError, ProbStepLog, ProbLow, ProbUp, 0, Count, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_, _)), + retract(up(_)). + + + +/* bestfirst(GoalsList, Number, Amount, MinError, ProbStep, + * LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) + * ----------------------------------------------------------------------------- + * This recursive supporting predicate performs resolution for current iteration, + * handles equivalent BDDs (lower and upper one) and calls itself if the current + * probability error is still bigger than the given minimum error. + * + * INPUT + * - GoalsList: given list of goal to work on. + * - FoundList: given list of achieved solutions. + * - Amount: max number of solution considered by each iteration. + * - MinError: minimum error (closing condition). + * - ProbStep: probability step. + * - Count0: number of BDDs already handled by the algorithm. + * - ResTime0: cpu time already spent on performing resolution. + * - BddTime0: cpu time already spent on handling BDDs. + * + * OUTPUT + * - LowerProb1: resulting lower bound probability for the given list of goals. + * - UpperProb1: resulting upper bound probability for the given list of goals. + * - Count1: number of BDDs handled. + * - ResTime1: cpu time spent on performing resolution. + * - BddTime1: cpu time spent on handling BDDs. + */ +bestfirst(GoalsList, Number, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + main(GoalsList, Amount, ProbStep, List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + Count2 is Count0 + 2, + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + Count1 = Count2, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + bestfirst(Incomplete, Next, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count2, Count1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* main(GoalsList, Amount, ProbStep, Pending) + * ------------------------------------------------ + * This tail recursive predicate takes the given GoalsList and tries to solve + * the first given Amount quads with the given ProbStep bound on probability, + * one at a time. After each resolution step, it merges the new solutions to the + * current list of solutions so that each time it can consider the most + * promising solution. It finally returns the list of pending solutions, if any. + * + * INPUT + * - GoalsList: current list of goals to solve. + * - Amount: current number of goals to solve. + * - ProbStep: incremental probability step for bound. + * + * OUTPUT + * - Sorted: desired sorted (by non increasing prob) results. + */ +main([], _Amount, _Step, []) :- !. +%% Closing condition: stop if no more goals (pending list is an empty list). + +main(Pending, Amount, _Step, Pending) :- + Amount =< 0, !. + %% Closing condition: stop if reached desired amount (pending list is current list). + +main([Prob0-(Gnd0, Var0, Goals0)|Tail], Amount, Step, Pending) :- + %% Note: Current list is surely not empty. + %% Note: A certain amount is surely still needed. + Bound is Prob0 + Step, + findall(Prob1-(Gnd1, Var1, Goals1), + explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)), + List), + %% Find all the solutions reacheable from the first quad. + sort(List, Sorted), + merge(Tail, Sorted, Complete), + + Needed is Amount - 1, + %% Count current quad as considered. + main(Complete, Needed, Step, Pending). + %% Recursive call: consider next quad (updating pending list). + %% Note: Complete list is sorted; this assures we always consider best quad. + + + +/* merge(SortedA, SortedB, Sorted) + * ------------------------------- + * This tail recursive predicate merges the quads in SortedA and SortedB list by + * non-increasing values of Prob and returns the desired unique Sorted list. + * The SortedA and SortedB lists must be sorted. + * + * INPUT + * - SortedA: first sorted list of quads. + * - SortedB: second sorted list of quads. + * + * OUTPUT + * - Sorted: resulting unique sorted list of quads. + */ +merge(Sorted, [], Sorted) :- !. +%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). + +merge([], Sorted, Sorted). +%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). + +merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbA-(GndA, VarA, GoalsA)|Tail]) :- + ProbA >= ProbB, !, + merge(TailA, [ProbB-(GndB, VarB, GoalsB)|TailB], Tail). + %% Recursive call: use the first quad (merge the rest of the first list with the second one). + +merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbB-(GndB, VarB, GoalsB)|Tail]) :- +% ProbA < ProbB, !, + merge([ProbA-(GndA, VarA, GoalsA)|TailA], TailB, Tail). + %% Recursive call: use the second quad (merge the first list with the rest of the second one). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/bestk.pl b/packages/cplint/approx/bestk.pl new file mode 100644 index 000000000..7a47c8fd5 --- /dev/null +++ b/packages/cplint/approx/bestk.pl @@ -0,0 +1,528 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(Goals, Prob, ResTime, BddTime) + * ------------------------------------ + * This predicate computes the probability of a given list of goals using an + * iterative deepening, probability bounded algorithm. + * It also returns the number of handled BDDs and the CPUTime spent performing + * resolution and spent handling the BDDs. + * + * Note: when their derivation is cut, negative goals are added to the head of + * the goals' list to be solved during the following iteration. + * + * INPUT + * - GoalsList: given list of goal to work on. It can contains variables: the + * predicate returns in backtracking all the solutions and their equivalent + * lower and upper bound probability. + * + * OUTPUT + * - Prob: resulting lower bound probability for the given list of goals. + * - ResTime: CPU time spent on performing resolution. + * - BddTime: CPU time spent on handling BDDs. + */ +solve(Goals, Prob, ResTime, BddTime) :- + setting(k, K), + setting(prob_step, ProbStep), + ProbStepLog is log(ProbStep), + % NB: log(1.0) == 0.0 !!! + bestk([0.0-0.0-([], [], Goals)], K, ProbStepLog, Prob, ResTime, BddTime). + + + +/* bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) + * ----------------------------------------------------- + * This recursive supporting predicate performs resolution for current iteration, + * sticks with the best complete solutions only and considers their equivalent + * BDD to compute their probability. + * + * INPUT + * - GoalsList: given list of goal to work on. + * - K: number of solution to consider. + * - ProbStep: value used to update the probability bound. + * + * OUTPUT + * - Prob: resulting probability (actaully a lower bound) for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + main(GoalsList, K, ProbStep, BestK), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(1), + insert_full_ptree(BestK, 1), + bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), + delete_ptree(1), + run_file('bdd.txt','bdd.par', Temp), + (Temp == timeout -> + Prob is -1.0; + Prob is Temp), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime is (ElapBddTime / 1000). + + + +/* main(Goals, K, ProbStep, Best) + * ------------------------------ + * This tail recursive predicate returns the Best K complete solutions to the + * given Goals. The probability bound is dinamically computed at each iteration. + * + * INPUT + * - Goals: list of goals to achive. + * - K: desired number of solutions. + * - ProbStep: value used to update the probability bound. + * + * OUTPUT + * - Best: list of best solutions (at most k). + */ +main(Goals, K, ProbStep, Best) :- + K > 0, + main(Goals, ProbStep, K, 0.0, [], Best). + +main([], _ProbStep, _Left, _Worst, Best, Best). + +main(Goals, ProbStep, Left0, Worst0, Best0, Best1) :- + findall(Prob1-Bound-(Gnd1, Var1, Goals1), + (member(Prob0-Bound0-(Gnd0, Var0, Goals0), Goals), Bound is Bound0+ ProbStep, explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + Found), + %% sepkeepbest(Found, Left0, Left2, Worst0, Worst2, Best0, Best2, [], Incomplete), + separate_main(Found, [], Complete, [], _UpperList, [], Incomplete), + keepbest(Complete, Left0, Left2, Worst0, Worst2, Best0, Best2), + main(Incomplete, ProbStep, Left2, Worst2, Best2, Best1). + + + +/* sepkeepbest(Found, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) + * ---------------------------------------------------------------------------- + * This tail recursive predicate analyzes the given list of solutions found and + * returns the list of (K at most) best complete solutions and the whole list of + * incomplete solutions for a full B&B behaviour. + * The given worst value permits some optimization, such as immediate skipping + * of very bad solutions. + * + * INPUT + * - Found: list of solutions found. + * - Left0: actual amount of items still needed to have K solutions. + * - Worst0: value of the actual worst complete solution kept. + * - List0: actual list of best complete solutions. + * - Next0: actual list of incomplete solutions. + * + * OUTPUT + * - Left1: final amount of items still needed to have K solutions. + * - Worst1: value of the final worst complete solution kept. + * - List1: final list of best complete solutions. + * - Next1: final list of incomplete solutions. + */ +sepkeepbest([], Left, Left, Worst, Worst, List, List, Next, Next) :- !. +%% Closing condition: stop if no more results (current values are now final values). + +sepkeepbest([Prob0-(_Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- + Prob0 =< Worst0, !, + sepkeepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- + Prob0 > Worst0, !, + discard(Prob0-(Gnd0, [], []), List0, List2, Worst2), + sepkeepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, [], [])|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- !, + insert(Prob0-(Gnd0, [], []), List0, Worst0, List2, Worst2), + Left2 is Left0 - 1, + sepkeepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1, Next0, Next1). + +sepkeepbest([Prob0-(Gnd0, Var0, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + sepkeepbest(Tail, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). + + + +/* separate(List, Low, Up, Next) + * ----------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([Prob0-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-(Gnd0, Var0, Goals)|Next1]) :- + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate_main([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate_main([Prob0-_Bound0-(Gnd0, [], [])|Tail], Low0, [Prob0-(Gnd0, [], [])|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, + separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate_main([Prob0-Bound0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Next1]) :- + separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_prob(Var, 1, Prob), + append(Gnd0, Var, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, [], Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_prob(Var, 1, Prob), + append(Gnd0, Var, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, [], Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* keepbest(List, K, BestK) + * ------------------------ + * This tail recursive predicate parses the given list of quads and returns the + * list of its best k quads. If the given list of quads contains less than k + * items, the predicate returns them all. + * + * INPUT + * - List: list of quads to parse. + * - K: desired number of quads. + * + * OUTPUT + * - BestK: final list of (at most) best k quads. + */ +keepbest(List, K, BestK) :- + K > 0, + keepbest(List, K, _Left, 0.0, _Worst, [], BestK). + +/*keepbest([], _Left, _Worst, List, List). + +keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Worst, List0, List1) :- + Prob =< Worst, !, + keepbest(Tail, 0, Worst, List0, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Worst, List0, List1) :- + Prob > Worst, !, + discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), + keepbest(Tail, 0, Worst2, List2, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], Left, Worst, List0, List1) :- + insert(Prob-(Gnd, Var, Goals), List0, Worst, List2, Worst2), + Left2 is Left - 1, + keepbest(Tail, Left2, Worst2, List2, List1).*/ + + + +keepbest([], Left, Left, Worst, Worst, List, List). + +keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- + Prob =< Worst0, !, + keepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- + Prob > Worst0, !, + discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), + keepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1). + +keepbest([Prob-(Gnd, Var, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1) :- + insert(Prob-(Gnd, Var, Goals), List0, Worst0, List2, Worst2), + Left2 is Left0 - 1, + keepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1). + + + +/* insert(Prob-(Gnd, Var, Goals), Sorted0, Worst0, Sorted1, Worst1) + * ---------------------------------------------------------------- + * This tail recursive predicate inserts the given quad into the given sorted + * list and returns the final sorted list. The input list must be sorted. + * It also updates the prob value of the worst quad. + * + * INPUT + * - Prob-(Gnd, Var, Goals): quad to insert. + * - Sorted0: sorted list to insert the quad into. + * - Worst0: current worst prob value. + * + * OUTPUT + * - Sorted1: the final sorted list. + * - Worst1: the final worst prob value. + */ +insert(Prob-(Gnd, Var, Goals), [], _Worst, [Prob-(Gnd, Var, Goals)], Prob). + +insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst, [Prob-(Gnd, Var, Goals), Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst) :- + Prob >= Prob_i, !. + +insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst0, [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst1) :- + Prob < Prob_i, !, + insert(Prob-(Gnd, Var, Goals), Tail, Worst0, Next, Worst1). + + + +/* discard(Prob-(Gnd, Var, Goals), Sorted0, Sorted1, Worst) + * -------------------------------------------------------- + * This tail recursive predicate inserts the given quad into the given sorted + * list, removes the last quad from it and returns the final sorted list. + * The given sorted list contains at least one quad and must be sorted. + * Previous worst prob value is not needed because it necessarely changes and + * the new value is not known in advance. + * It also updates the prob value of the worst quad. + * + * INPUT + * - Prob-(Gnd, Var, Goals): quad to insert. + * - Sorted0: sorted list to insert the quad into. + * + * OUTPUT + * - Sorted1: the final sorted list. + * - Worst: the final worst prob value. + */ +discard(Prob-(Gnd, Var, Goals), [_Prob_i-(_Gnd_i, _Var_i, _Goals_i)], [Prob-(Gnd, Var, Goals)], Prob) :- !. + +discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob-(Gnd, Var, Goals)|Next], Worst) :- + Prob >= Prob_i, !, + discard(Prob_i-(Gnd_i, Var_i, Goals_i), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). + +discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst) :- + Prob < Prob_i, !, + discard(Prob-(Gnd, Var, Goals), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_full_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the ground part of the given list in a trie. + */ +insert_full_ptree([], _Trie). + +insert_full_ptree([_Prob-(Gnd, _Var, _Goals)|Tail], Trie) :- + reverse(Gnd, Gnd1), + insert_ptree(Gnd1, Trie), + insert_full_ptree(Tail, Trie). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). + + diff --git a/packages/cplint/approx/deepdyn.pl b/packages/cplint/approx/deepdyn.pl new file mode 100644 index 000000000..8bdb8b981 --- /dev/null +++ b/packages/cplint/approx/deepdyn.pl @@ -0,0 +1,352 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File deepit.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) + * --------------------------------------------------- + * This predicate computes the probability of a given list of goals using an + * iterative deepening algorithm. It also returns the number of handled BDDs and + * CPUTime spent in performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - ProbLow: the resulting lowerbound probability for the given list of goals. + * - ProbUp: the resulting upperbound probability for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- + setting(min_error, MinError), + setting(prob_step, ProbStep), + + LogProbStep is log(ProbStep), + + assert(low(0,0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + deepdyn([0.0-([], [], GoalsList)], 0, MinError, LogProbStep, ProbLow, ProbUp, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_,_)), + retract(up(_)). + + + +/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where +CG is the list of ground choices, C is the list of non-ground choices, +P is the probability of CG, G is the list of goals to be resolved, +Succ is the list of explanations found so far, PB is the current prob bound, +ProbL0,ProbU0 are the lower/upper prob bounds */ + +deepdyn(GoalsList, Number, MinError, ProbStep, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Prob1-(Gnd1, Var1, Goals1), + (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), ProbBound is log(Prob0) + ProbStep, explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + deepdyn(Incomplete, Next, MinError, ProbStep, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/deepit.pl b/packages/cplint/approx/deepit.pl new file mode 100644 index 000000000..52c71047c --- /dev/null +++ b/packages/cplint/approx/deepit.pl @@ -0,0 +1,352 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File deepit.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) + * --------------------------------------------------- + * This predicate computes the probability of a given list of goals using an + * iterative deepening algorithm. It also returns the number of handled BDDs and + * CPUTime spent in performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - ProbLow: the resulting lowerbound probability for the given list of goals. + * - ProbUp: the resulting upperbound probability for the given list of goals. + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- + setting(min_error, MinError), + setting(prob_bound, ProbBound), + + LogProbBound is log(ProbBound), + + assert(low(0,0.0)), + assert(up(1.0)), + init_ptree(1), + + % NB: log(1.0) == 0.0 !!! + deepit([0.0-([], [], GoalsList)], 0, MinError, LogProbBound, ProbLow, ProbUp, 0, ResTime, 0, BddTime), + + delete_ptree(1), + retract(low(_,_)), + retract(up(_)). + + + +/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where +CG is the list of ground choices, C is the list of non-ground choices, +P is the probability of CG, G is the list of goals to be resolved, +Succ is the list of explanations found so far, PB is the current prob bound, +ProbL0,ProbU0 are the lower/upper prob bounds */ + +deepit(GoalsList, Number, MinError, ProbBound, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Prob1-(Gnd1, Var1, Goals1), + (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), + List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime2 is ResTime0 + ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(2), + init_ptree(3), + separate(List, [], LowerList0, [], UpperList, [], Incomplete), + insert_list_ptree(LowerList0, 1), + insert_list_ptree(UpperList, 2), + merge_ptree(1,2,3), + + length(LowerList0, DeltaLow), + Next is Number + DeltaLow, + eval_lower(Next, ProbLow), + + length(UpperList, DeltaUp), + Temp is Next + DeltaUp, + eval_upper(Temp, ProbUp), + + delete_ptree(2), + delete_ptree(3), + + % Taking elapsed times... + statistics(walltime, [_, ElapBddTime]), + BddTime2 is BddTime0 + (ElapBddTime / 1000), + + % Is the current error lower than the minimum error? + (ProbUp - ProbLow < MinError -> + % Setting output parameters' values... + LowerProb1 = ProbLow, + UpperProb1 = ProbUp, + ResTime1 = ResTime2, + BddTime1 = BddTime2; + + % Keeping on iterating with accumulated values... + % sufficient without negation: + % D1 = DB, + % necessary for negation + deepit(Incomplete, Next, MinError, ProbBound, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). + + + +/* separate(List, Low, Up, Next) + * ---------------------------------- + * This tail recursive predicate parses the input list and builds the list for + * the lower bound, the upper bound and the pending goals. + * The upper bound list contains both the items of the lower bound list and the + * incomplete ones. + * + * INPUT + * - List: input list. + * + * OUTPUT + * - Low: list for lower bound. + * - Up: list for upper bound. + * - Next: list of pending goals. + */ +separate(List, Low, Up, Next) :- +%% Polarization: initial low, up and next lists are empty. + separate(List, [], Low, [], Up, [], Next). + +separate([], Low, Low, Up, Up, Next, Next) :- !. +%% Closing condition: stop if no more results (current lists are now final lists). + +separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + +separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- + get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), + append(Gnd0, Gnd2, Gnd1), + Prob1 is Prob0 + log(Prob2), + separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). + + + +/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) + * -------------------------------------------------------------------------- + * This tail recursive predicate reads current explanation and returns the + * explanation after the current iteration without dropping below the given + * probability bound. + * + * INPUT + * - ProbBound: the desired probability bound; + * - Prob0-(Gnd0, Var0, Goals0): current explanation + * - Gnd0: list of current ground choices, + * - Var0: list of current non-ground choices, + * - Prob0: probability of Gnd0, + * - Goals0: list of current goals. + * + * OUTPUT + * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration + * - Gnd1: list of final ground choices, + * - Var1: list of final non-ground choices, + * - Prob1: probability of Gnd1, + * - Goals1: list of final goals. + */ +explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. +%% Closing condition: stop if no more goals (input values are output values). + +explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- + %% Closing condition: stop if bound has been reached (input values are output values). + Prob =< ProbBound, !. + +% Negation, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call((\+ Head)), + explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + %% Recursive call: consider next goal (building next values) + +% Negation +explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, + list2and(HeadList, Head), % ... + findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> + separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), + (PendingGoals \= [] -> + Var2 = Var0, + Gnd2 = Gnd0, + Goals1 = [\+ Head|Goals], + explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); + %% Recursive call: consider next goal (building next values) + + choose_clausesc(Gnd0, Var0, LowerBound, Var), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). + %% Recursive call: consider next goal (building next values) + +% Main, builtin +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + builtin(Head), !, + call(Head), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, def_rule +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + def_rule(Head, Goals0), + append(Goals0, Tail, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + +% Main, find_rulec +explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- + find_rulec(Head, (R, S, N), Goals, Var0, _Prob), + explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- + (member_eq((N, R, S), Var0); + member_eq((N, R, S), Gnd0)), !, + append(Goals, Goals0, Goals2), + get_groundc(Var0, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). + % Recursive call: consider next goal (building next values) + +explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- + append(Var0, [(N, R, S)], Var), + append(Goals, Goals0, Goals2), + get_groundc(Var, Gnd, Var2, 1, Prob), + append(Gnd0, Gnd, Gnd2), + Prob2 is Prob0 + log(Prob), + explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). + % Recursive call: consider next goal (building next values) + + + +/* eval_lower(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the lower bound by + * running an external command (BDD resolution via files). + */ +eval_lower(Number, Prob) :- + low(Number, Prob). + +eval_lower(Number, ProbLow) :- + Number > 0, + low(OldNumber, _), + Number \= OldNumber, + bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), + run_file('bddl.txt', 'bddl.par', NewProbLow), + (NewProbLow = timeout -> + low(_, ProbLow); + + ProbLow = NewProbLow, + retract(low(_, _)), + assert(low(Number, ProbLow))). + + + +/* eval_upper(Number, Prob) + * ------------------------ + * This predicate evaluates if there are proofs for the upper bound by + * running an external command (BDD resolution via files). + */ +eval_upper(0, ProbUp) :- !, + low(_, ProbUp). + +eval_upper(_Number, ProbUp) :- + bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), + run_file('bddu.txt', 'bddu.par', NewProbUp), + (NewProbUp = timeout-> + up(ProbUp); + ProbUp = NewProbUp, + retract(up(_)), + assert(up(ProbUp))). + + + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/exact.pl b/packages/cplint/approx/exact.pl new file mode 100644 index 000000000..ead21b34c --- /dev/null +++ b/packages/cplint/approx/exact.pl @@ -0,0 +1,235 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(system)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(tptreefile). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, Prob, ResTime, BddTime) + * ---------------------------------------- + * This predicate computes the probability of a given list of goals using an + * exact algorithm. It also returns the number of handled BDDs (trivial but + * present for simmetry with other solving predicates), CPUTime spent in + * performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - Prob: the resulting exact probability for the given list of goals. + * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + + % Performing resolution... + findall(Deriv, exact(GoalsList, Deriv), List), + + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + + % Building and solving equivalent bdds... + init_ptree(1), + fatto(List), + insert_list_ptree(List, 1), + bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), + delete_ptree(1), + run_file('bdd.txt','bdd.par', Temp), + (Temp == timeout -> + Prob is -1.0; + Prob is Temp), + + % Taking elapsed times + statistics(walltime, [_, ElapBddTime]), + BddTime is ElapBddTime/1000. + + + +/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set +and returns an output C set +The C set is a list of triple (N, R, S) where +- N is the index of the head atom used, starting from 0 +- R is the index of the non ground rule used, starting from 1 +- S is the substitution of rule R, in the form of a list whose elements + are of the form 'VarName'=value +*/ +exact(GoalsList, Deriv) :- + exact(GoalsList, [], Deriv). + +exact([], C, C) :- !. + +exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([bagof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([setof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([setof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([\+ H|T], CIn, COut) :- + builtin(H), !, + call((\+ H)), + exact(T, CIn, COut). + +exact([\+ H |T], CIn, COut) :- !, + list2and(HL, H), + findall(D, find_deriv(HL, D), L), + choose_clauses(CIn, L, C1), + exact(T, C1, COut). + +exact([H|T], CIn, COut) :- + builtin(H), !, + call(H), + exact(T, CIn, COut). + +exact([H|T], CIn, COut) :- + def_rule(H, B), + append(B, T, NG), + exact(NG, CIn, COut). + +exact([H|T], CIn, COut) :- + find_rule(H, (R, S, N), B, CIn), + solve_pres(R, S, N, B, T, CIn, COut). + + + +solve_pres(R, S, N, B, T, CIn, COut) :- + member_eq((N, R, S), CIn), !, + append(B, T, NG), + exact(NG, CIn, COut). + +solve_pres(R, S, N, B, T, CIn, COut) :- + append(CIn, [(N, R, S)], C1), + append(B, T, NG), + exact(NG, C1, COut). + + + +/* find_rule(G, (R, S, N), Body, C) + * -------------------------------- + * This predicate takes a goal G and the current C set and returns the index R + * of a disjunctive rule resolving with G together with the index N of the + * resolving head, the substitution S and the Body of the rule. + */ +find_rule(H, (R, S, N), Body, C) :- + rule(H, _P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). + +/* run_file(BDDFile, BDDParFile, Prob) + * ----------------------------------- + * This predicate calls for the resolution of a BDD via file. + */ +run_file(BDDFile, BDDParFile, Prob) :- + ResultFile = 'result.txt', + library_directory(Dir), + setting(timeout, BDDTime), + (BDDTime = no -> + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); + atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), + + %statistics(walltime,_), + + shell(Command, Return), + (Return =\= 0 -> + Status = timeout, + Prob = Status; + + see(ResultFile), + read(elapsed_construction(_TimeConstruction)), + read(probability(Prob)), + read(elapsed_traversing(_TimeTraversing)), + seen, + + %write(probability(Prob)),nl, + %read(_), + %delete_file(ResultFile), + + Status = ok + % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) + ). + + %statistics(walltime,[_,E3]), + %format(user,'~w ms BDD processing~Number',[E3]), + % format("Status ~a~Number",[Status]). + + + +/* insert_list_ptree([Head|Tail], Trie) + * ------------------------------------ + * This predicate inserts the given list in a trie. + */ +insert_list_ptree([], _Trie). + +insert_list_ptree([Head|Tail], Trie) :- + reverse(Head, Head1), + insert_ptree(Head1, Trie), + insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/exact_mem.pl b/packages/cplint/approx/exact_mem.pl new file mode 100644 index 000000000..a429fc598 --- /dev/null +++ b/packages/cplint/approx/exact_mem.pl @@ -0,0 +1,189 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File best.pl + * Goal oriented interpreter for LPADs based on SLDNF + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +/* DA MODIFICARE AFFINCHE' USI IL NUOVO CPLINT_INT */ +/* PARTE BDD IN UN FILE SEPARATO? */ + + +:- dynamic rule/4, def_rule/2. + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ +:- use_module(library(lists)). +:- use_module(library(ugraphs)). +:- use_module(params). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* INITIALIZATION + * -------------- + * The following predicate enables the cplint specific features for the program. + */ +:- load_foreign_files(['cplint'], [], init_my_predicates). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* solve(GoalsList, Prob, ResTime, BddTime) + * ---------------------------------------- + * This predicate computes the probability of a given list of goals using an + * exact algorithm. It also returns the number of handled BDDs (trivial but + * present for simmetry with other solving predicates), CPUTime spent in + * performing resolution and in handling the BDDs. + * + * INPUT + * - GoalsList: given list of goal to work on. + * + * OUTPUT + * - Prob: the resulting exact probability for the given list of goals. + * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). + * - ResTime: cpu time spent on performing resolution. + * - BddTime: cpu time spent on handling BDDs. + */ +solve(GoalsList, Prob, ResTime, BddTime) :- + % Resetting the clocks... + statistics(walltime, [_, _]), + % Performing resolution... + findall(Deriv, exact(GoalsList, Deriv), List), + % Taking elapsed times... + statistics(walltime, [_, ElapResTime]), + ResTime is ElapResTime/1000, + % Building and solving equivalent bdds... + build_formula(List, Formula, [], Var), + var2numbers(Var, 0, NewVar), + (setting(save_dot, true) -> + format("Variables: ~p~n", [Var]), + compute_prob(NewVar, Formula, Prob, 1); + compute_prob(NewVar, Formula, Prob, 0)), + + % Taking elapsed times + statistics(walltime, [_, ElapBddTime]), + BddTime is ElapBddTime/1000. + +/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set +and returns an output C set +The C set is a list of triple (N, R, S) where +- N is the index of the head atom used, starting from 0 +- R is the index of the non ground rule used, starting from 1 +- S is the substitution of rule R, in the form of a list whose elements + are of the form 'VarName'=value +*/ +exact(GoalsList, Deriv) :- + exact(GoalsList, [], Deriv). + +exact([], C, C) :- !. + +exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([bagof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + bagof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L, [], C1), + remove_duplicates_eq(C1, C2), + exact(T, C2, COut). + +exact([setof(V, EV^G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), EV^exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([setof(V, G, L)|T], CIn, COut) :- !, + list2and(GL, G), + setof((V, C), exact(GL, CIn, C), LD), + length(LD, N), + build_initial_graph(N, GrIn), + build_graph(LD, 0, GrIn, Gr), + clique(Gr, Clique), + build_Cset(LD, Clique, L1, [], C1), + remove_duplicates(L1, L), + exact(T, C1, COut). + +exact([\+ H|T], CIn, COut) :- + builtin(H), !, + call((\+ H)), + exact(T, CIn, COut). + +exact([\+ H |T], CIn, COut) :- !, + list2and(HL, H), + findall(D, find_deriv(HL, D), L), + choose_clauses(CIn, L, C1), + exact(T, C1, COut). + +exact([H|T], CIn, COut) :- + builtin(H), !, + call(H), + exact(T, CIn, COut). + +exact([H|T], CIn, COut) :- + def_rule(H, B), + append(B, T, NG), + exact(NG, CIn, COut). + +exact([H|T], CIn, COut) :- + find_rule(H, (R, S, N), B, CIn), + solve_pres(R, S, N, B, T, CIn, COut). + + + +solve_pres(R, S, N, B, T, CIn, COut) :- + member_eq((N, R, S), CIn), !, + append(B, T, NG), + exact(NG, CIn, COut). + +solve_pres(R, S, N, B, T, CIn, COut) :- + append(CIn, [(N, R, S)], C1), + append(B, T, NG), + exact(NG, C1, COut). + + + +/* find_rule(G, (R, S, N), Body, C) + * -------------------------------- + * This predicate takes a goal G and the current C set and returns the index R + * of a disjunctive rule resolving with G together with the index N of the + * resolving head, the substitution S and the Body of the rule. + */ +find_rule(H, (R, S, N), Body, C) :- + rule(H, _P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). diff --git a/packages/cplint/approx/montecarlo.pl b/packages/cplint/approx/montecarlo.pl new file mode 100644 index 000000000..049780a99 --- /dev/null +++ b/packages/cplint/approx/montecarlo.pl @@ -0,0 +1,275 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: montecarlo.pl + * Solves LPADs with Monte Carlo (main predicate: solve(Goals, Prob, Samples, ResTime, BddTime) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +/* EXTERNAL FILE + * ------------- + * The following libraries are required by the program to work fine. + */ + +:- dynamic rule/4, def_rule/2, randx/1, randy/1, randz/1. + +:- use_module(library(lists)). +:- use_module(library(random)). +:- use_module(library(ugraphs)). +:- use_module(params). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* SOLVING PREDICATES + * ------------------ + * The predicates in this section solve any given problem with several class of + * algorithms. + * + * Note: the original predicates (no more need and eligible to be deleted) have + * been moved to the end of the file. + */ + +/* Starting seed. */ +randx(1). +randy(1). +randz(1). + +/* newsample + * --------- + * This predicate programmatically generates and sets a new seed for the + * algorithm. + */ +newsample :- + retract(randx(X)), + randy(Y), + randz(Z), + (X =< 30269 -> + SuccX is X + 1, + assert(randx(SuccX)); + assert(randx(1)), + retract(randy(_)), + (Y =< 30307 -> + SuccY is Y + 1, + assert(randy(SuccY)); + assert(randy(1)), + retract(randz(_)), + (Z =< 30323 -> + SuccZ is Z + 1, + assert(randz(SuccZ)); + assert(randz(1))))), + setrand(rand(X, Y, Z)). + + +/* solve(Goals, Samples, Time, Lower, Prob, Upper) + * ----------------------------------------------- + * This predicate calls the Monte Carlo solving method for the current problem. + * It requires the Goals to fulfil and returns the number of Samples considered, + * the Time required, the extimated Probability and the Lower and Upper bounds. + * + * INPUT + * - Goals: given list of goals to fulfil. + * + * OUTPUT + * - Samples: number of samples considered to solve the problem. + * - Time: time required to solve the problem. + * - Lower: lower end of the confidence interval. + * - Prob: extimated probability. + * - Upper: upper end of the confidence interval. + */ +solve(Goals, Samples, Time, Lower, Prob, Upper) :- + % Retrieving functional parameters... + setting(k, K), + setting(min_error, MinError), + % Resetting the clocks... + statistics(walltime, [_, _]), + % Performing resolution... + montecarlo(0, 0, Goals, K, MinError, Samples, Lower, Prob, Upper), + % Taking elapsed times... + statistics(walltime, [_, ElapTime]), + % Setting values... + Time is ElapTime/1000. + + + +/* montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) + * --------------------------------------------------------------------------- + * This tail recursive predicate solves the problem currently in memory with a + * Monte Carlo approach. + * It requires the number of samples and successes so far (Count and Success), + * the desired list of Goals to fulfil, the number K of samples to consider at + * once and the threshold MinError for the binomial proportion confidence + * interval. + * It returns the total number of Samples considered, the Lower and Upper ends + * of the the binomial proportion confidence interval and the extimated Prob. + * + * INPUT + * - Count: number of samples considered so far. + * - Success: number of successfull samples considered so far. + * - Goals: list of goals to fulfil. + * - K: number of samples to consider at once. + * - MinError: threshold for the binomial proportion confidence interval. + * + * OUTPUT + * - Samples: total number of samples considered. + * - Lower: lower end of the the binomial proportion confidence interval. + * - Prob: extimated probability. + * - Upper: upper end of the the binomial proportion confidence interval. + * + * NB: This method is based on the binomial proportion confidence interval and + * the Brown's rule of thumb to avoid the case the sample proportion is + * exactly 0.0 or 1.0 and doesn't make use of BDDs. + */ +montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) :- + /* Decomment the following line if you want to test the algorithm with an + incremental seed for each sample. + newsample, + */ + main(Goals, [], _Explan, Valid), + N is Count + 1, + S is Success + Valid, + (N mod K =:= 0 -> +% format("Advancement: ~t~d/~d~30+~n", [S, N]), + P is S / N, + D is N - S, + Semi is 2 * sqrt(P * (1 - P) / N), + Int is 2 * Semi, + /* N * P > 5; N * S / N > 5; S > 5 + * N (1 - P) > 5; N (1 - S / N) > 5; N (N - S) / N > 5; N - S > 5 + */ + ((S > 5, D > 5, (Int < MinError; Int =:= 0)) -> + Samples is N, + Lower is P - Semi, + Prob is P, + Upper is P + Semi; + montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)); + montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)). + + + +/* null + * ---- + * This is dummy predicate to use sparingly when needed. + * Typical uses are as spying predicate during tracing or as dead branch in + * ( -> ; ) predicate. + */ +null. + + + +/* main(Goals, Explan0, Explan1, Valid) + * ------------------------------------ + * This tail recursive predicate looks for a solution to the given Goals + * starting from the given Explan0 and returns the final Explan and 1 (0 otherwise) if it is a + * Valid sample for Montecarlo. + */ +main([], Explan, Explan, 1). + +main([\+ Goal|Tail], Explan0, Explan1, Valid) :- + builtin(Goal), !, + (call((\+ Goal)) -> + main(Tail, Explan0, Explan1, Valid); + Explan1 = Explan0, + Valid = 0). + +main([Goal|Tail], Explan0, Explan1, Valid) :- + builtin(Goal), !, + (call(Goal) -> + main(Tail, Explan0, Explan1, Valid); + Explan1 = Explan0, + Valid = 0). + +main([Goal|Tail], Explan0, Explan1, Valid) :- + findall((IsSample, Goals, Step), explore([Goal|Tail], Explan0, IsSample, Goals, Step), List), + cycle(List, Explan0, Explan1, Valid). + + + +/* explore([Goal|Tail], Explan, Valid, Goals, Step) + * ------------------------------------------------ + * This predicate looks for a Body and the Step to reach it from the given Goal + * and Explan and returns 1 (0 otherwise) if they are a Valid sample for + * Montecarlo. + * Please note that Body and Step are meaningfull only when Valid is 1. + * + * This comment has to be fixed. + */ +explore([Goal|Tail], _Explan, 1, Goals, []) :- + def_rule(Goal, Body), + append(Body, Tail, Goals). + +explore([Goal|Tail], Explan, Valid, Goals, Step) :- + findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)), + append(Body, Tail, Goals), + (member_eq((HeadID, RuleID, Subst), Explan) -> + Step = []; + Step = [(HeadID, RuleID, Subst)]). + + + +/* findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)) + * --------------------------------------------------------------- + * This predicate finds a rule that matches with the given Goal and Explan and + * returns 1 (0 otherwise) if it is a Valid sample for Montecarlo. + * If the sample is Valid, the other return parameters are also meaningfull and + * are the Body and (RuleID, Subst, HeadIS) of the rule that matches with the + * given Goal and Explan. + * + * This comment has to be fixed. + */ +findrule(Goal, Explan, Valid, Body, (HeadId, RuleId, Subst)) :- + rule(Goal, _Prob, Required, RuleId, Subst, _Heads, HeadsList, Body), + sample(HeadsList, HeadId), + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Explan), + (HeadId =:= Required -> + Valid = 1; + Valid = 0). + + + +/* sample(Heads, RuleId, HeadId, Subst) + * ------------------------------------ + * This tail recursive predicate samples a random head among the given Heads of + * the given RuleId and returns its HeadId and Subst. + */ +sample(HeadList, HeadId) :- + random(Prob), + sample(HeadList, 0, 0, Prob, HeadId), !. + +sample([_HeadTerm:HeadProb|Tail], Index, Prev, Prob, HeadId) :- + Succ is Index + 1, + Next is Prev + HeadProb, + (Prob =< Next -> + HeadId = Index; + sample(Tail, Succ, Next, Prob, HeadId)). + + + +/* cycle([(IsSample, Body, [Step])|Tail], Explan0, Explan1, Found) + * ----------------------------------------------------------------- + * This tail recursive predicate analyzes the given Body and Step to reach it + * and returns 0 as it's not a Valid sample for Montecarlo. + * If it is Valid, it looks for a solution to the Body and the given Goals + * starting from the Step and the given Explan and returns 1 if it finds a + * Valid one. + * If it does not find it, it considers the next Body and Step and returns their + * Valid value. + * + * NB: This comment needs to be updated. + */ +cycle([], Explan, Explan, 0). + +cycle([(0, _Goals, Step)|Tail], Explan0, Explan1, IsSample) :- !, + append(Step, Explan0, Explan2), + cycle(Tail, Explan2, Explan1, IsSample). + +cycle([(1, Goals, Step)|Tail], Explan0, Explan1, IsSample) :- + append(Step, Explan0, Explan), + main(Goals, Explan, Explan2, Valid), + (Valid == 1 -> + Explan1 = Explan2, + IsSample = 1; + cycle(Tail, Explan2, Explan1, IsSample)). diff --git a/packages/cplint/approx/params.pl b/packages/cplint/approx/params.pl new file mode 100644 index 000000000..d3470e49f --- /dev/null +++ b/packages/cplint/approx/params.pl @@ -0,0 +1,122 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: params.pl + * Defines and sets parameters needed by other predicates (main: set). + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic setting/2. + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + +/* PARAMETER LIST + * -------------- + * The following list of parameters declares a few constants used along the + * program. + * The default value for each parameter can be changed using the following + * predicate: + * + * set(Parameter, Value). + */ + +/* epsilon_parsing + * --------------- + * This parameter shows the probability's granularity during parsing. + * + * Default value: 0.00001 + * Applies to: parsing + */ +setting(epsilon_parsing, 0.00001). + +/* ground_body + * ----------- + * This parameter tells if both the head and the body of each clause must be + * ground, or else the head only. + * In case the body contains variables not present in the head, it represents + * an existential event. + * + * Default value: false + * Applies to: parsing + */ +setting(ground_body, false). + +/* k + * - + * This parameter shows the amount of items of the same type to consider at once. + * + * Default value: 64 + * Applies to: bestfirst, bestk, montecarlo + */ +setting(k, 64). + +/* min_error + * --------- + * This parameter shows the threshold for the probability interval. + * + * Default value: 0.01 + * Applies to: bestfirst, montecarlo + */ +setting(min_error, 0.01). + +/* prob_bound + * ---------- + * This parameter shows the initial probability bound in a probability bounded + * method. + * + * Default value: 0.01 + * Applies to: deepit + */ +setting(prob_bound, 0.001). + +/* prob_step + * --------- + * This parameter shows the probability deepening step in a probability bounded + * method. + * + * Default value: 0.001 + * Applies to: bestfirst, bestk + */ +setting(prob_step, 0.001). + +/* save_dot + * -------- + * This parameter tells if a .dot file for variables has be created. + * + * Default value: false + * Applies to: bestfirst, bestk, exact + */ +setting(save_dot, false). + +/* timeout + * ------- + * This parameter shows the time to wait before killing a bdd solving process. + * + * Default value: 300 + * Applies to: bestfirst, bestk, exact + */ +setting(timeout, 300). + + + + + +/* PREDICATES + * ---------- + * The predicates in this section interact with the parameters defined above. + */ + +/* set(Parameter, Value) + * --------------------- + * This predicate drops any previously saved value for the given parameter and + * associates it to the new given value. + * + * INPUT + * - Parameter: target parameter for the given new value. + * - Value: new value to assign to the given parameter. + */ +set(Parameter, Value) :- + retract(setting(Parameter, _)), + assert(setting(Parameter, Value)). diff --git a/packages/cplint/approx/parsing.pl b/packages/cplint/approx/parsing.pl new file mode 100644 index 000000000..0e32ddaeb --- /dev/null +++ b/packages/cplint/approx/parsing.pl @@ -0,0 +1,344 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: parsing.pl + * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +:- use_module(params). +:- use_module(utility). + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* parse(File) + * ----------- + * This predicate parses the given .cpl file. + * + * Note: it can be called more than once without exiting yap + * + * INPUT + * - File: .cpl file to parse, without extension. + */ +parse(File) :- + atom_concat(File, '.cpl', FileName), + open(FileName, read, FileHandle), + read_clauses(FileHandle, Clauses), + close(FileHandle), + retractall(rule_by_num(_, _, _, _, _)), + retractall(rule(_, _, _, _, _, _, _, _)), + retractall(def_rule(_, _)), + process_clauses(Clauses, 1). + + + + + + + +/* assert_rules() + * -------------- + * This tail recursive predicate parses the given list of (Head:Prob) couples + * and stores them incrementally as rules along with the other parameters. + * + * INPUT + * - Head: current head part. + * - Prob: probability of the current head part. + * - Index: index of the current head part. + * - Subst: substitution for the current head part. + * - Choices: list of current head parts indexes. + * - HeadList: complete head or list of its parts. + * - BodyList: complete body or list of its parts. + */ +assert_rules([], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. % Closing condition. + +assert_rules(['':_Prob], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. + +assert_rules([Head:Prob|Tail], Index, HeadList, BodyList, Choices, Id, Subst) :- + assertz(rule(Head, Prob, Index, Id, Subst, Choices, HeadList, BodyList)), + Next is Index + 1, + assert_rules(Tail, Next, Id, Subst, Choices, HeadList, BodyList). + + + +delete_var(_Var, [], []). + +delete_var(Var, [Current|Tail], [Current|Next]) :- + Var \== Current, !, + delete_var(Var, Tail, Next). + +delete_var(_Var, [_Head|Tail], Tail). + + + +extract_vars(Variable, Var0, Var1) :- + var(Variable), !, + (member_eq(Variable, Var0) -> + Var1 = Var0; + append(Var0, [Variable], Var1)). + +extract_vars(Term, Var0, Var1) :- + Term=..[_F|Args], + extract_vars_list(Args, Var0, Var1). + + + +extract_vars_clause(end_of_file, []). + +extract_vars_clause(Clause, VarNames, Couples) :- + (Clause = (Head :- _Body) -> + true; + Head = Clause), + extract_vars(Head, [], Vars), + pair(VarNames, Vars, Couples). + + + +extract_vars_list([], Var, Var). + +extract_vars_list([Term|Tail], Var0, Var1) :- + extract_vars(Term, Var0, Var), + extract_vars_list(Tail, Var, Var1). + + + +get_var(Var, [Var]) :- + var(Var), !. % Succeeds if Var is currently a free variable, otherwise fails. + +get_var(Var, Value) :- + Var=..[_F|Args], + get_var_list(Args, Value). + + + +get_var_list([], []). + +get_var_list([Head|Tail], [Head|Next]) :- + var(Head), !, + get_var_list(Tail, Next). + +get_var_list([Head|Tail], Vars) :- !, + get_var(Head, Var), + append(Var, Next, Vars), + get_var_list(Tail, Next). + + + +/* ground_prob(HeadList) + * --------------------- + * This tail recursive predicate verifies if the given HeadList is ground. + * + * INPUT + * - HeadList: list of heads to verify its groundness. + */ +ground_prob([]). + +ground_prob([_Head:ProbHead|Tail]) :- + ground(ProbHead), % Succeeds if there are no free variables in the term ProbHead. + ground_prob(Tail). + + + +pair(_VarName, [], []). + +pair([VarName = _Var|TailVarName], [Var|TailVar], [VarName = Var|Tail]) :- + pair(TailVarName, TailVar, Tail). + + + +/* process_head(HeadList, CompleteHeadList) + * ---------------------------------------- + * Note: if the annotation in the head are not ground, the null atom is not + * added and the eventual formulas are not evaluated. + */ +process_head(HeadList, GroundHeadList) :- + ground_prob(HeadList), !, + process_head_ground(HeadList, 0, GroundHeadList); + +process_head(HeadList, HeadList). + + + +/* process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) + * ---------------------------------------------------------------- + */ +process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) :- + ProbLast is 1 - Prob - ProbHead, + setting(epsilon_parsing, Eps), + EpsNeg is - Eps, + ProbLast > EpsNeg, + (ProbLast > Eps -> + Null = ['':ProbLast]; + Null = []). + +process_head_ground([Head:ProbHead|Tail], Prob, [Head:ProbHead|Next]) :- + ProbNext is Prob + ProbHead, + process_head_ground(Tail, ProbNext, Next). + + + + + + + + + + + + + + + + + +/* process_body(BodyList, Vars0, Vars1) + * ------------------------------------ + * Note: setof must have a goal in the form B^G, where B is a term containing + * the existential variables. + */ +process_body([], Vars, Vars). + +process_body([setof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + get_var(B, VarsB), + remove_vars(VarsA, Vars0, Vars3), + remove_vars(VarsB, Vars3, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([setof(A, _G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + remove_vars(VarsA, Vars0, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([bagof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + get_var(B, VarsB), + remove_vars(VarsA, Vars0, Vars3), + remove_vars(VarsB, Vars3, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([bagof(A, _G, _L)|Tail], Vars0, Vars1) :- !, + get_var(A, VarsA), + remove_vars(VarsA, Vars0, Vars2), + process_body(Tail, Vars2, Vars1). + +process_body([_Head|Tail], Vars0, Vars1) :- !, + process_body(Tail, Vars0, Vars1). + + + + + + + +process_clauses([(end_of_file, [])], _Id). + +/* NB: il seguente predicato è stato commentato perchè usa predicati non conformi + * a quelli attesi (vedi 'rule\5'). + * / +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head=uniform(A, P, L), !, + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + remove_vars([P], BodyListValue, V2), + append(BodyList, [length(L, Tot), nth0(Number, L, P)], BL1), + append(V2, ['Tot'=Tot], V3), + assertz(rule(Id, V3, _NH, uniform(A:1/Tot, L, Number), BL1)), + assertz(rule_uniform(A, Id, V3, _NH, 1/Tot, L, Number, BL1)), + N1 is Id+1, + process_clauses(Tail, N1). */ + +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head = (_;_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), + assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([((Head :- Body), Value)|Tail], Id) :- + Head = (_:_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + list2and(BodyList, Body), + process_body(BodyList, Value, BodyListValue), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), + assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([((Head :- Body), _V)|Tail], Id) :- !, + list2and(BodyList, Body), + assert(def_rule(Head, BodyList)), + process_clauses(Tail, Id). + +process_clauses([(Head, Value)|Tail], Id) :- + Head=(_;_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), + assertz(rule_by_num(Id, Value, NH, HeadList, [])), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([(Head, Value)|Tail], Id) :- + Head=(_:_), !, + list2or(HeadListOr, Head), + process_head(HeadListOr, HeadList), + length(HeadList, LH), + listN(0, LH, NH), + assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), + assertz(rule_by_num(Id, Value, NH, HeadList, [])), + N1 is Id+1, + process_clauses(Tail, N1). + +process_clauses([(Head, _V)|Tail], Id) :- + assert(def_rule(Head, [])), + process_clauses(Tail, Id). + + + +read_clauses(Stream, Clauses) :- + (setting(ground_body, true) -> + read_clauses_ground_body(Stream, Clauses); + read_clauses_exist_body(Stream, Clauses)). + + + +read_clauses_exist_body(Stream, [(Clause, Vars)|Next]) :- + read_term(Stream, Clause, [variable_names(VarNames)]), + extract_vars_clause(Clause, VarNames, Vars), + (Clause = end_of_file -> + Next = []; + read_clauses_exist_body(Stream, Next)). + + + +read_clauses_ground_body(Stream, [(Clause, Vars)|Next]) :- + read_term(Stream, Clause, [variable_names(Vars)]), + (Clause = end_of_file -> + Next = []; + read_clauses_ground_body(Stream, Next)). + + + +remove_vars([], Vars, Vars). + +remove_vars([Head|Tail], Vars0, Vars1) :- + delete_var(Head, Vars0, Vars2), + remove_vars(Tail, Vars2, Vars1). diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops b/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops new file mode 100644 index 000000000..625e8a0b0 --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops @@ -0,0 +1,47 @@ +K 25 +svn:wc:ra_dav:version-url +V 76 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs +END +ProblogBDD.c +K 25 +svn:wc:ra_dav:version-url +V 89 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/ProblogBDD.c +END +simplecudd.h +K 25 +svn:wc:ra_dav:version-url +V 89 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/simplecudd.h +END +general.h +K 25 +svn:wc:ra_dav:version-url +V 86 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/general.h +END +ProblogBDDclus.c +K 25 +svn:wc:ra_dav:version-url +V 93 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/ProblogBDDclus.c +END +simplecudd.c +K 25 +svn:wc:ra_dav:version-url +V 89 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/simplecudd.c +END +Makefile +K 25 +svn:wc:ra_dav:version-url +V 85 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/Makefile +END +general.c +K 25 +svn:wc:ra_dav:version-url +V 86 +/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/general.c +END diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/entries b/packages/cplint/approx/simplecuddLPADs/.svn/entries new file mode 100644 index 000000000..879bf69da --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/entries @@ -0,0 +1,273 @@ +9 + +dir +2205 +https://ds.ing.unife.it/svn/cplint/cplint/trunk/cplint_new/approx_src/simplecuddLPADs +https://ds.ing.unife.it/svn/cplint + + + +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +8b881860-fc2d-0410-9739-81b0d24abadf + + + + + + +0 + +simplecudd.h +file + + + + +2010-03-15T10:08:01.000000Z +07e7f1b7c2ef1d2e345358b8a993d452 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +17432 + +ProblogBDD.c +file + + + + +2010-03-15T10:08:01.000000Z +98293257daff85df3f703c11e3f049a4 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +35511 + +general.h +file + + + + +2010-03-15T10:08:01.000000Z +c4a07810ee4ab51ec579ded4d2467a4b +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +12030 + +ProblogBDDclus.c +file + + + + +2010-03-15T10:08:01.000000Z +9c3bee903af5a2c4e26d3c413d3ef4f5 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +36201 + +simplecudd.c +file + + + + +2010-03-15T10:08:01.000000Z +d92d01ea87ba9caa86311df989c8f6a2 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +67867 + +Makefile +file + + + + +2010-03-15T10:08:01.000000Z +7b252aa4540f97f9955e69cd66cf022e +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +1335 + +general.c +file + + + + +2010-03-15T10:08:01.000000Z +581112590eceb12912be10381846d207 +2010-03-15T10:14:10.890703Z +2154 +friguzzi + + + + + + + + + + + + + + + + + + + + + +13543 + diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/format b/packages/cplint/approx/simplecuddLPADs/.svn/format new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/format @@ -0,0 +1 @@ +9 diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base new file mode 100644 index 000000000..f8afe98ed --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base @@ -0,0 +1,55 @@ +# +# default base directory for YAP installation +# (EROOT for architecture-dependent files) +# +prefix = /home/rzf/usr/local +ROOTDIR = $(prefix) +EROOTDIR = ${prefix} +# +# where the binary should be +# +BINDIR = $(EROOTDIR)/bin +# +# where YAP should look for libraries +# +LIBDIR=$(EROOTDIR)/lib/Yap +DESTDIR=$(prefix)/share/Yap +# +# +CC=gcc +# +# +# You shouldn't need to change what follows. +# +INSTALL=/usr/bin/install -c +INSTALL_DATA=${INSTALL} -m 644 +INSTALL_PROGRAM=${INSTALL} +SHELL=/bin/sh +RANLIB=ranlib +SHLIB_CFLAGS=-shared -fPIC +SHLIB_SUFFIX=.so +CWD=$(PWD) +# + +CUDD = cudd-2.4.1 +DYNAMIC = +CFLAGS = -DBP_FREE -O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes -I/home/rzf/usr/local/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include +INCLUDE = +LINKFLAGS = -L/home/rzf/usr/local/lib -L/lib/ -lm -lglu +LINKLIBS = -lcu -lm -lglu -lglib-2.0 + +default: LPADBDD + +LPADBDD: ProblogBDD.o simplecudd.o general.o + @echo Making ProblogBDD... + @echo Copyright T. Mantadelis, A. Kimmig, B. Gutmann and Katholieke Universiteit Leuven 2008 + $(CC) $(LINKLIBS) $(LINKFLAGS) -I/home/rzf/usr/local/include ProblogBDD.o simplecudd.o general.o $(LINKLIBS) $(LINKFLAGS) -o LPADBDD + +%.o : $(srcdir)/%.c + $(CC) $(CFLAGS) $(INCLUDE) $(DYNAMIC) -c $< + +clean: + rm -f *.o LPADBDD + +install: default + $(INSTALL_PROGRAM) LPADBDD $(DESTDIR) diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base new file mode 100644 index 000000000..269ae533d --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base @@ -0,0 +1,871 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * +* and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * +* File: ProblogBDD.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" +#include +#include + +typedef struct _parameters { + int loadfile; + int savedfile; + int exportfile; + int inputfile; + int debug; + int errorcnt; + int *error; + int method; + int queryid; + int timeout; + double sigmoid_slope; + int online; + int maxbufsize; + char *ppid; +} parameters; + +typedef struct _gradientpair { + double probability; + double gradient; +} gradientpair; + +typedef struct _extmanager { + DdManager *manager; + DdNode *t, *f; + hisqueue *his; + namedvars varmap; +} extmanager; + + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); +double Prob(extmanager MyManager, DdNode *node, int comp); +int correctPosition(int index,variable v,int posBVar); +double ret_prob(extmanager MyManager, DdNode * bdd); + + + +int argtype(const char *arg); +void printhelp(int argc, char **arg); +parameters loadparam(int argc, char **arg); +parameters params; + +void handler(int num); +void pidhandler(int num); +void termhandler(int num); + +double sigmoid(double x, double slope); +void myexpand(extmanager MyManager, DdNode *Current); +double CalcProbability(extmanager MyManager, DdNode *Current); +double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); +int patterncalculated(char *pattern, extmanager MyManager, int loc); +char * extractpattern(char *thestr); + +int main(int argc, char **arg) { + clock_t start, endc, endt; + double elapsedc,elapsedt; + + extmanager MyManager; + DdNode *bdd; + bddfileheader fileheader; + int i, ivarcnt, code; + gradientpair tvalue; + double probability = -1.0; + char *varpattern; + varpattern = NULL; + code = -1; + params = loadparam(argc, arg); + if (params.errorcnt > 0) { + printhelp(argc, arg); + for (i = 0; i < params.errorcnt; i++) { + fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); + } + return -1; + } + + if (params.online == 0 && params.loadfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: you must specify a loading file.\n"); + return -1; + } + + if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { + printhelp(argc, arg); + fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); + return -1; + } + + if (params.debug) DEBUGON; + RAPIDLOADON; + SETMAXBUFSIZE(params.maxbufsize); + + signal(SIGINT, termhandler); + if (params.ppid != NULL) { + signal(SIGALRM, pidhandler); + alarm(5); + } else { + signal(SIGALRM, handler); + alarm(params.timeout); + } + if (params.online) { + MyManager.manager = simpleBDDinit(0); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(1, 0); + bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); + ivarcnt = GetVarCount(MyManager.manager); + } else { + fileheader = ReadFileHeader(arg[params.loadfile]); + switch(fileheader.filetype) { + case BDDFILE_SCRIPT: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); + if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; + start = clock(); + bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); + endc=clock(); + elapsedc = ((double) (endc - start)) / CLOCKS_PER_SEC; + printf("elapsed_construction(%lf).\n",elapsedc); + ivarcnt = fileheader.varcnt; + break; + case BDDFILE_NODEDUMP: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); + bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); + ivarcnt = fileheader.varcnt; + break; + default: + fprintf(stderr, "Error: not a valid file format to load.\n"); + return -1; + break; + } + } + alarm(0); + + // problem specifics + + if (bdd != NULL) { + ivarcnt = RepairVarcnt(&MyManager.varmap); + code = 0; + /* + if (params.inputfile != -1) { + if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; + if (!all_loaded(MyManager.varmap, 1)) return -1; + }*/ + MyManager.his = InitHistory(ivarcnt); + if (params.method != 0) { + switch(arg[params.method][0]) { + case 'g': + for (i = 0; i < MyManager.varmap.varcnt; i++) { + if (MyManager.varmap.vars[i] != NULL) { + varpattern = extractpattern(MyManager.varmap.vars[i]); + if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { + tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); + probability = tvalue.probability; + double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; + if (varpattern == NULL) { + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); + } else { + varpattern[strlen(varpattern) - 2] = '\0'; + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); + } + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + } + if (varpattern != NULL) free(varpattern); + } else { + fprintf(stderr, "Error: no variable name given for parameter.\n"); + } + } + if (probability < 0.0) { + // no nodes, so we have to calculate probability ourself + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + } + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'l': + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'p': + printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); + break; + case 'o': + onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); + break; + default: + myexpand(MyManager, bdd); + break; + } + } else { + start=clock(); + // simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); + printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); + endt=clock(); + elapsedt = ((double) (endt - start)) / CLOCKS_PER_SEC; + printf("elapsed_traversing(%lf).\n",elapsedt); +// myexpand(MyManager, bdd); + } + if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); + if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + free(MyManager.his); + } + if (MyManager.manager != NULL) { + KillBDD(MyManager.manager); +exit(code); + free(MyManager.varmap.dvalue); + free(MyManager.varmap.ivalue); + free(MyManager.varmap.dynvalue); + for (i = 0; i < MyManager.varmap.varcnt; i++) + { + free(MyManager.varmap.vars[i]); + free(MyManager.varmap.mvars[i].probabilities); + free(MyManager.varmap.mvars[i].booleanVars); + } + free(MyManager.varmap.vars); + free(MyManager.varmap.mvars); + free(MyManager.varmap.bVar2mVar); + } + if (params.error != NULL) free(params.error); + + return code; + +} + +/* Shell Parameters handling */ + +int argtype(const char *arg) { + if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; + if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; + if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; + if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; + if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; + if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; + if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; + if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; + if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; + if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; + if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; + if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; + return -1; +} + +void printhelp(int argc, char **arg) { + fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); + fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); + fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); + fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); + fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); + fprintf(stderr, "Optional parameters:\n"); + fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); + fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); + fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); + fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); + fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); + fprintf(stderr, "Extra parameters:\n"); + fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); + fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); + fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); + fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); + fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); + fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); +} + +parameters loadparam(int argc, char **arg) { + int i; + parameters params; + params.loadfile = -1; + params.savedfile = -1; + params.exportfile = -1; + params.method = 0; + params.inputfile = -1; + params.debug = 0; + params.errorcnt = 0; + params.queryid = 0; + params.timeout = 0; + params.sigmoid_slope = 1.0; + params.online = 0; + params.maxbufsize = 0; + params.ppid = NULL; + params.error = (int *) malloc(argc * sizeof(int)); + for (i = 1; i < argc; i++) { + switch(argtype(arg[i])) { + case 0: + if (argc > i + 1) { + i++; + params.loadfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 2: + if (argc > i + 1) { + i++; + params.exportfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 3: + if (argc > i + 1) { + i++; + params.method = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 4: + if (argc > i + 1) { + i++; + params.inputfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 5: + printhelp(argc, arg); + break; + case 6: + params.debug = 1; + break; + case 7: + if (argc > i + 1) { + i++; + params.queryid = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 8: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.timeout = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 9: + if (argc > i + 1) { + i++; + params.savedfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 10: + if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { + i++; + params.sigmoid_slope = atof(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 11: + params.online = 1; + break; + case 12: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.maxbufsize = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 13: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); + strcpy(params.ppid, arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + default: + params.error[params.errorcnt] = i; + params.errorcnt++; + break; + } + } + return params; +} + +/* Error Handlers */ + +void handler(int num) { + fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); + exit(-1); +} + +void pidhandler(int num) { + char *s; + if (params.timeout > 0) { + params.timeout -= 5; + if (params.timeout <= 0) { + fprintf(stderr, "Error: Timeout exceeded.\n"); + exit(-1); + } + } + s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); + strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); + if (system(s) != 0) exit(4); + signal(SIGALRM, pidhandler); + alarm(5); + free(s); +} + +void termhandler(int num) { + exit(3); +} + +/* General Functions */ + +double sigmoid(double x, double slope) { + return 1 / (1 + exp(-x * slope)); +} + +/* Debugging traverse function */ + +void myexpand(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + printf("%s\n", curnode); + if ((Current != MyManager.t) && (Current != MyManager.f) && + ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + printf("l(%s)->", curnode); + myexpand(MyManager, l); + printf("h(%s)->", curnode); + myexpand(MyManager, h); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); + } +} + +/* Angelikas Algorithm */ + +double CalcProbability(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + double lvalue, hvalue, tvalue; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) return 1.0; + if (Current == MyManager.f) return 0.0; + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcProbability(MyManager, l); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcProbability(MyManager, h); + tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; + tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); + return tvalue; +} + +/* Bernds Algorithm */ + +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + gradientpair lvalue, hvalue, tvalue; + double this_probability; + double *gradient; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) { + tvalue.probability = 1.0; + tvalue.gradient = 0.0; + return tvalue; + } + if (Current == MyManager.f) { + tvalue.probability = 0.0; + tvalue.gradient = 0.0; + return tvalue; + } + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { + tvalue.probability = Found->dvalue; + tvalue.gradient = *((double *) Found->dynvalue); + return tvalue; + } + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); + this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); + tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; + tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; + if ((GetIndex(Current) == TargetVar) || + ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { + tvalue.gradient += hvalue.probability - lvalue.probability; + } + gradient = (double *) malloc(sizeof(double)); + *gradient = tvalue.gradient; + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); + return tvalue; +} + +char * extractpattern(char *thestr) { + char *p; + int i = 0, sl = strlen(thestr); + while((thestr[i] != '_') && (i < sl)) i++; + if (i == sl) return NULL; + i++; + p = (char *) malloc(sizeof(char) * (i + 2)); + strncpy(p, thestr, i); + p[i] = '*'; + p[i + 1] = '\0'; + return p; +} + +int patterncalculated(char *pattern, extmanager MyManager, int loc) { + int i; + if (pattern == NULL) return 0; + for (i = loc - 1; i > -1; i--) + if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; + return 0; +} + +double Prob(extmanager MyManager, DdNode *node, int comp) +/* compute the probability of the expression rooted at node +nodes is used to store nodes for which the probability has alread been computed +so that it is not recomputed + */ +{ + int mVarIndex,nBit,index; + variable v; + hisnode *Found; + double res; + double value; + + + //printf("Prob node %d\n",node); + //index=Cudd_NodeReadIndex(node); + //printf("Prob INdex %d\n",index); + if (Cudd_IsConstant(node)) + { + value=Cudd_V(node);//node->type.value; + //printf("Value %e comp %d\n",value,comp); + if (comp)//Cudd_IsComplement(node)) + //return (1.0-value); + //if (value>0) + { +// printf("return 0"); + return 0.0; + } + else + { +// printf("return 1"); + return 1.0; + } +/*else + if (value>0) + return 1.0; + else + return 0.0; +*/ //return value; + } + else +{ + Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); + + if (Found!=NULL) + { + //printf("value found %e\n",Found->dvalue); + return Found->dvalue; + } + else + { + index=Cudd_NodeReadIndex(node); + //printf("node absent %d comp %d\n",node,comp); + //mVarIndex=array_fetch(int,bVar2mVar,index); + mVarIndex=MyManager.varmap.bVar2mVar[index]; + //v=array_fetch(variable,vars,mVarIndex); + v=MyManager.varmap.mvars[mVarIndex]; + nBit=v.nBit; +// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); + //scanf("%d",&r); + res=ProbBool(MyManager,node,0,nBit,0,v,comp); + //printf("New val %e\n",res); + AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); + return res; + } +} +} + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) +/* explores a group of binary variables making up the multivalued variable v */ +{ + DdNode *T,*F; + double p,res; + double * probs; + int index; +// printf("ProbBool nBit %d\n",nBit); + //scanf("%d",&r); + probs=v.probabilities; + if (nBit==0) + { + //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); +// printf("bits %d v.nbit %d\n",bits,v.nBit); + if (bits>=v.nVal) + //if (comp) + { + //printf("bits>=v.nbit return 0\n"); + return 0.0; + } + //else + //{printf("return 0\n"); + //return 1.0;}} + else + { + // printf("Val %d\n",bits); + + //p=array_fetch(double,probs,bits); + p=probs[bits]; + //printf("prob %e\n",p); + res=p*Prob(MyManager,node,comp); + //printf("prob %e\n",p); + //printf("bottom %e\n",res); + return res; + } + } + else + { + //if (correctPosition(node->index,v,node,posBVar)) + index=Cudd_NodeReadIndex(node); + //printf("index %d\n",Cudd_NodeReadIndex(node)); + if (correctPosition(index,v,posBVar)) + { + //printf("node %d\n",node); + T = Cudd_T(node);//node->type.kids.T; + F = Cudd_E(node);//node->type.kids.E; + bits=bits<<1; + //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); + res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); + //printf("comp %d ",comp); + comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); + //printf("comp %d \n",comp); +res=res+ + ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); + //printf("res 2 %e\n",res); + return res; + } + else + { + //printf("absent var\n"); + bits=bits<<1; + // printf("Var =1\n"); + res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res 1 %e\n",res); +//printf("var =0\n"); + res=res+ + ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); + // printf("res 2 %e\n",res); +return res; + } + } +} + +int correctPosition(int index,variable v,int posBVar) +/* returns 1 is the boolean variable with index posBVar is in the correct position +currently explored by ProbBool */ +{ + int bvar; +//printf("posbvar %d\n",posBVar); +//printf("length %d\n",array_n(v.booleanVars)); + //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); + bvar=v.booleanVars[posBVar]; + + // return var->index==index; +return(bvar==index); +} + +double ret_prob(extmanager MyManager, DdNode * bdd) +{ + double prob; + /* dividend is a global variable used by my_hash + it is equal to an unsigned int with binary representation 11..1 */ + prob=Prob(MyManager,bdd,Cudd_IsComplement(bdd)); + + return prob; + +} diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base new file mode 100644 index 000000000..a799895bc --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base @@ -0,0 +1,895 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * +* and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * +* File: ProblogBDD.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" +#include + +typedef struct _parameters { + int loadfile; + int savedfile; + int exportfile; + int inputfile; + int debug; + int errorcnt; + int *error; + int method; + int queryid; + int timeout; + double sigmoid_slope; + int online; + int maxbufsize; + char *ppid; +} parameters; + +typedef struct _gradientpair { + double probability; + double gradient; +} gradientpair; + +typedef struct _extmanager { + DdManager *manager; + DdNode *t, *f; + hisqueue *his; + namedvars varmap; +} extmanager; + +GHashTable * nodes; /* hash table that associates nodes with their probability if already + computed, it is defined in glib */ +unsigned long dividend; + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); +double Prob(extmanager MyManager, DdNode *node, int comp); +int correctPosition(int index,variable v, DdNode * node,int posBVar); +gint my_equal(gconstpointer v,gconstpointer v2); +guint my_hash(gconstpointer key); +void dealloc(gpointer key,gpointer value,gpointer user_data); +double ret_prob(extmanager MyManager, DdNode * bdd); + + + +int argtype(const char *arg); +void printhelp(int argc, char **arg); +parameters loadparam(int argc, char **arg); +parameters params; + +void handler(int num); +void pidhandler(int num); +void termhandler(int num); + +double sigmoid(double x, double slope); +void myexpand(extmanager MyManager, DdNode *Current); +double CalcProbability(extmanager MyManager, DdNode *Current); +double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); +int patterncalculated(char *pattern, extmanager MyManager, int loc); +char * extractpattern(char *thestr); + +int main(int argc, char **arg) { + extmanager MyManager; + DdNode *bdd; + bddfileheader fileheader; + int i, ivarcnt, code; + gradientpair tvalue; + double probability = -1.0; + char *varpattern; + varpattern = NULL; + code = -1; + params = loadparam(argc, arg); + if (params.errorcnt > 0) { + printhelp(argc, arg); + for (i = 0; i < params.errorcnt; i++) { + fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); + } + return -1; + } + + if (params.online == 0 && params.loadfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: you must specify a loading file.\n"); + return -1; + } + + if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { + printhelp(argc, arg); + fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); + return -1; + } + + if (params.debug) DEBUGON; + RAPIDLOADON; + SETMAXBUFSIZE(params.maxbufsize); + + signal(SIGINT, termhandler); + if (params.ppid != NULL) { + signal(SIGALRM, pidhandler); + alarm(5); + } else { + signal(SIGALRM, handler); + alarm(params.timeout); + } + if (params.online) { + MyManager.manager = simpleBDDinit(0); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(1, 0); + bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); + ivarcnt = GetVarCount(MyManager.manager); + } else { + fileheader = ReadFileHeader(arg[params.loadfile]); + switch(fileheader.filetype) { + case BDDFILE_SCRIPT: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); + if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; + bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); + ivarcnt = fileheader.varcnt; + break; + case BDDFILE_NODEDUMP: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); + bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); + ivarcnt = fileheader.varcnt; + break; + default: + fprintf(stderr, "Error: not a valid file format to load.\n"); + return -1; + break; + } + } + alarm(0); + + // problem specifics + + if (bdd != NULL) { + ivarcnt = RepairVarcnt(&MyManager.varmap); + code = 0; + /* + if (params.inputfile != -1) { + if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; + if (!all_loaded(MyManager.varmap, 1)) return -1; + }*/ + MyManager.his = InitHistory(ivarcnt); + if (params.method != 0) { + switch(arg[params.method][0]) { + case 'g': + for (i = 0; i < MyManager.varmap.varcnt; i++) { + if (MyManager.varmap.vars[i] != NULL) { + varpattern = extractpattern(MyManager.varmap.vars[i]); + if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { + tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); + probability = tvalue.probability; + double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; + if (varpattern == NULL) { + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); + } else { + varpattern[strlen(varpattern) - 2] = '\0'; + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); + } + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + } + if (varpattern != NULL) free(varpattern); + } else { + fprintf(stderr, "Error: no variable name given for parameter.\n"); + } + } + if (probability < 0.0) { + // no nodes, so we have to calculate probability ourself + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + } + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'l': + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'p': + printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); + break; + case 'o': + onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); + break; + default: + myexpand(MyManager, bdd); + break; + } + } else { + //simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); + printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); +// myexpand(MyManager, bdd); + } + if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); + if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + free(MyManager.his); + } + if (MyManager.manager != NULL) { + KillBDD(MyManager.manager); + free(MyManager.varmap.dvalue); + free(MyManager.varmap.ivalue); + free(MyManager.varmap.dynvalue); + for (i = 0; i < MyManager.varmap.varcnt; i++) + { + free(MyManager.varmap.vars[i]); + free(MyManager.varmap.mvars[i].probabilities); + free(MyManager.varmap.mvars[i].booleanVars); + } + free(MyManager.varmap.vars); + free(MyManager.varmap.mvars); + free(MyManager.varmap.bVar2mVar); + } + if (params.error != NULL) free(params.error); + + return code; + +} + +/* Shell Parameters handling */ + +int argtype(const char *arg) { + if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; + if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; + if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; + if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; + if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; + if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; + if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; + if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; + if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; + if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; + if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; + if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; + return -1; +} + +void printhelp(int argc, char **arg) { + fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); + fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); + fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); + fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); + fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); + fprintf(stderr, "Optional parameters:\n"); + fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); + fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); + fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); + fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); + fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); + fprintf(stderr, "Extra parameters:\n"); + fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); + fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); + fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); + fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); + fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); + fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); +} + +parameters loadparam(int argc, char **arg) { + int i; + parameters params; + params.loadfile = -1; + params.savedfile = -1; + params.exportfile = -1; + params.method = 0; + params.inputfile = -1; + params.debug = 0; + params.errorcnt = 0; + params.queryid = 0; + params.timeout = 0; + params.sigmoid_slope = 1.0; + params.online = 0; + params.maxbufsize = 0; + params.ppid = NULL; + params.error = (int *) malloc(argc * sizeof(int)); + for (i = 1; i < argc; i++) { + switch(argtype(arg[i])) { + case 0: + if (argc > i + 1) { + i++; + params.loadfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 2: + if (argc > i + 1) { + i++; + params.exportfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 3: + if (argc > i + 1) { + i++; + params.method = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 4: + if (argc > i + 1) { + i++; + params.inputfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 5: + printhelp(argc, arg); + break; + case 6: + params.debug = 1; + break; + case 7: + if (argc > i + 1) { + i++; + params.queryid = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 8: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.timeout = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 9: + if (argc > i + 1) { + i++; + params.savedfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 10: + if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { + i++; + params.sigmoid_slope = atof(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 11: + params.online = 1; + break; + case 12: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.maxbufsize = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 13: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); + strcpy(params.ppid, arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + default: + params.error[params.errorcnt] = i; + params.errorcnt++; + break; + } + } + return params; +} + +/* Error Handlers */ + +void handler(int num) { + fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); + exit(-1); +} + +void pidhandler(int num) { + char *s; + if (params.timeout > 0) { + params.timeout -= 5; + if (params.timeout <= 0) { + fprintf(stderr, "Error: Timeout exceeded.\n"); + exit(-1); + } + } + s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); + strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); + if (system(s) != 0) exit(4); + signal(SIGALRM, pidhandler); + alarm(5); + free(s); +} + +void termhandler(int num) { + exit(3); +} + +/* General Functions */ + +double sigmoid(double x, double slope) { + return 1 / (1 + exp(-x * slope)); +} + +/* Debugging traverse function */ + +void myexpand(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + printf("%s\n", curnode); + if ((Current != MyManager.t) && (Current != MyManager.f) && + ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + printf("l(%s)->", curnode); + myexpand(MyManager, l); + printf("h(%s)->", curnode); + myexpand(MyManager, h); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); + } +} + +/* Angelikas Algorithm */ + +double CalcProbability(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + double lvalue, hvalue, tvalue; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) return 1.0; + if (Current == MyManager.f) return 0.0; + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcProbability(MyManager, l); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcProbability(MyManager, h); + tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; + tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); + return tvalue; +} + +/* Bernds Algorithm */ + +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + gradientpair lvalue, hvalue, tvalue; + double this_probability; + double *gradient; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) { + tvalue.probability = 1.0; + tvalue.gradient = 0.0; + return tvalue; + } + if (Current == MyManager.f) { + tvalue.probability = 0.0; + tvalue.gradient = 0.0; + return tvalue; + } + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { + tvalue.probability = Found->dvalue; + tvalue.gradient = *((double *) Found->dynvalue); + return tvalue; + } + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); + this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); + tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; + tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; + if ((GetIndex(Current) == TargetVar) || + ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { + tvalue.gradient += hvalue.probability - lvalue.probability; + } + gradient = (double *) malloc(sizeof(double)); + *gradient = tvalue.gradient; + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); + return tvalue; +} + +char * extractpattern(char *thestr) { + char *p; + int i = 0, sl = strlen(thestr); + while((thestr[i] != '_') && (i < sl)) i++; + if (i == sl) return NULL; + i++; + p = (char *) malloc(sizeof(char) * (i + 2)); + strncpy(p, thestr, i); + p[i] = '*'; + p[i + 1] = '\0'; + return p; +} + +int patterncalculated(char *pattern, extmanager MyManager, int loc) { + int i; + if (pattern == NULL) return 0; + for (i = loc - 1; i > -1; i--) + if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; + return 0; +} + +double Prob(extmanager MyManager, DdNode *node, int comp) +/* compute the probability of the expression rooted at node +nodes is used to store nodes for which the probability has alread been computed +so that it is not recomputed + */ +{ + int index,mVarIndex,nBit; + variable v; + hisnode *Found; + double res; + double value; + + + //index=node->index; + //printf("Prob node %d\n",node); + //index=Cudd_NodeReadIndex(node); + //printf("Prob INdex %d\n",index); + if (Cudd_IsConstant(node)) + { + value=Cudd_V(node);//node->type.value; + //printf("Value %e comp %d\n",value,comp); + if (comp)//Cudd_IsComplement(node)) + //return (1.0-value); + //if (value>0) + { +// printf("return 0"); + return 0.0; + } + else + { +// printf("return 1"); + return 1.0; + } +/*else + if (value>0) + return 1.0; + else + return 0.0; +*/ //return value; + } + else +{ + Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); + + if (Found!=NULL) + { + //printf("value found %e\n",*value_p); + return Found->dvalue; + } + else + { + index=Cudd_NodeReadIndex(node); + //printf("node absent %d comp %d\n",node,comp); + //mVarIndex=array_fetch(int,bVar2mVar,index); + mVarIndex=MyManager.varmap.bVar2mVar[index]; + //v=array_fetch(variable,vars,mVarIndex); + v=MyManager.varmap.mvars[mVarIndex]; + nBit=v.nBit; +// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); + //scanf("%d",&r); + res=ProbBool(MyManager,node,0,nBit,0,v,comp); + //printf("New val %e\n",res); + AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); + return res; + } +} +} + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) +/* explores a group of binary variables making up the multivalued variable v */ +{ + DdNode *T,*F; + double p,res; + double * probs; + int index; +// printf("ProbBool nBit %d\n",nBit); + //scanf("%d",&r); + probs=v.probabilities; + if (nBit==0) + { + //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); +// printf("bits %d v.nbit %d\n",bits,v.nBit); + if (bits>=v.nVal) + //if (comp) + { + //printf("bits>=v.nbit return 0\n"); + return 0.0; + } + //else + //{printf("return 0\n"); + //return 1.0;}} + else + { + // printf("Val %d\n",bits); + + //p=array_fetch(double,probs,bits); + p=probs[bits]; + //printf("prob %e\n",p); + res=p*Prob(MyManager,node,comp); + //printf("prob %e\n",p); + //printf("bottom %e\n",res); + return res; + } + } + else + { + //if (correctPosition(node->index,v,node,posBVar)) + index=Cudd_NodeReadIndex(node); + //printf("index %d\n",Cudd_NodeReadIndex(node)); + if (correctPosition(index,v,node,posBVar)) + { + //printf("node %d\n",node); + T = Cudd_T(node);//node->type.kids.T; + F = Cudd_E(node);//node->type.kids.E; + bits=bits<<1; + //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); + res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); + //printf("comp %d ",comp); + comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); + //printf("comp %d \n",comp); +res=res+ + ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); + //printf("res 2 %e\n",res); + return res; + } + else + { + //printf("absent var\n"); + bits=bits<<1; + // printf("Var =1\n"); + res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res 1 %e\n",res); +//printf("var =0\n"); + res=res+ + ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); + // printf("res 2 %e\n",res); +return res; + } + } +} + +int correctPosition(int index,variable v, DdNode * node,int posBVar) +/* returns 1 is the boolean variable with index posBVar is in the correct position +currently explored by ProbBool */ +{ + DdNode * bvar; +//printf("posbvar %d\n",posBVar); +//printf("length %d\n",array_n(v.booleanVars)); + //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); + bvar=v.booleanVars[posBVar]; + + // return var->index==index; +return(Cudd_NodeReadIndex(bvar)==index); +} + +gint my_equal(gconstpointer v,gconstpointer v2) +/* function used by GHashTable to compare two keys */ +{ + DdNode *a,*b; + a=*(DdNode **)v; + b=*(DdNode **)v2; + return (a==b); +} +guint my_hash(gconstpointer key) +/* function used by GHashTable to hash a key */ +{ + unsigned int h; + h=(unsigned int)((unsigned long) *((DdNode **)key) % dividend); + return h; +} +void dealloc(gpointer key,gpointer value,gpointer user_data) +{ + free(key); + free(value); +} +double ret_prob(extmanager MyManager, DdNode * bdd) +{ + int intBits,j; + double prob; + nodes=g_hash_table_new(my_hash,my_equal); + intBits=sizeof(unsigned int)*8; + /* dividend is a global variable used by my_hash + it is equal to an unsigned int with binary representation 11..1 */ + dividend=1; + for(j=1;j= sl) return 0; + if ((thestr[j] == pattern[i]) && patternmatch(pattern + i, thestr + j)) return 1; + } while(1); + } else { + j++; + if (j >= sl) return 0; + if (pattern[i] != thestr[j]) return 0; + } + } + return (pl == sl); +} diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base new file mode 100644 index 000000000..4441ed623 --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base @@ -0,0 +1,159 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: general.h * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include +#include +#include + +#define IsNumberDigit(c) ('0' <= c && c <= '9') +#define IsSignDigit(c) (c == '+' || c == '-') +#define isOperator(x) (x == '+' || x == '*' || x == '#' || x == '=') +#define freadline(fd) freadstr(fd, "\n"); + +int IsRealNumber(char *c); +int IsPosNumber(const char *c); +int IsNumber(const char *c); +char * freadstr(FILE *fd, const char *separators); +int CharIn(const char c, const char *in); +int patternmatch(char *pattern, char *thestr); diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base new file mode 100644 index 000000000..e361aeb91 --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base @@ -0,0 +1,1747 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: simplecudd.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" + +/* BDD manager initialization */ + +int _debug = 0; +int _RapidLoad = 0; +int _maxbufsize = 0; +int boolVars=0; + +DdManager* simpleBDDinit(int varcnt) { + DdManager *temp; + temp = Cudd_Init(varcnt, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0); + Cudd_AutodynEnable(temp, CUDD_REORDER_GROUP_SIFT); + Cudd_SetMaxCacheHard(temp, 1024*1024*1024); + Cudd_SetLooseUpTo(temp, 1024*1024*512); + if (_debug) + Cudd_EnableReorderingReporting(temp); + return temp; +} + +/* BDD tree travesrsing */ + +DdNode* HighNodeOf(DdManager *manager, DdNode *node) { + DdNode *tmp; + if (IsHigh(manager, node)) return HIGH(manager); + if (IsLow(manager, node)) return LOW(manager); + tmp = Cudd_Regular(node); + if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.T); + return tmp->type.kids.T; +} + +DdNode* LowNodeOf(DdManager *manager, DdNode *node) { + DdNode *tmp; + if (IsHigh(manager, node)) return HIGH(manager); + if (IsLow(manager, node)) return LOW(manager); + tmp = Cudd_Regular(node); + if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.E); + return tmp->type.kids.E; +} + +/* BDD tree generation */ + +DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddAnd(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddNand(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddOr(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddNor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddXor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddXnor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +/* file manipulation */ + +bddfileheader ReadFileHeader(char *filename) { + bddfileheader temp; + char *header; + temp.inputfile = NULL; + temp.version = 0; + temp.varcnt = 0; + temp.varstart = 0; + temp.intercnt = 0; + temp.filetype = BDDFILE_OTHER; + if ((temp.inputfile = fopen(filename, "r")) == NULL) { + perror(filename); + temp.filetype = BDDFILE_ERROR; + return temp; + } + // Read file header + if (!feof(temp.inputfile)) { + header = freadline(temp.inputfile); + temp.version = CheckFileVersion(header); + if (temp.version > -1) temp.filetype = (strlen(header) == 5) * BDDFILE_SCRIPT + (strlen(header) == 7) * BDDFILE_NODEDUMP; + free(header); + switch (temp.filetype) { + case BDDFILE_SCRIPT: + switch (temp.version) { + case 1: + fscanf(temp.inputfile, "%i\n", &temp.varcnt); + fscanf(temp.inputfile, "%i\n", &temp.bvarcnt); + fscanf(temp.inputfile, "%i\n", &temp.varstart); + fscanf(temp.inputfile, "%i\n", &temp.intercnt); + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + break; + case BDDFILE_NODEDUMP: + switch (temp.version) { + case 1: + fscanf(temp.inputfile, "%i\n", &temp.varcnt); + fscanf(temp.inputfile, "%i\n", &temp.varstart); + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + break; + case BDDFILE_OTHER: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + } + return temp; +} + +int CheckFileVersion(const char *version) { + if (strlen(version) < 5) return -1; + if (strlen(version) == 5 && version[0] == '@' && version[1] == 'B' && version[2] == 'D' && version[3] == 'D') return atoi(version + 4); + if (strlen(version) == 7 && version[0] == '@' && version[1] == 'N' && version[2] == 'O' && version[3] == 'D' + && version[4] == 'E' && version[5] == 'S') return atoi(version + 6); + return -1; +} + +int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) { + DdNode *f[1]; + int ret; + FILE *fd; + f[0] = Cudd_BddToAdd(manager, bdd); + fd = fopen(filename, "w"); + if (fd == NULL) { + perror(filename); + return -1; + } + ret = Cudd_DumpDot(manager, 1, f, NULL, NULL, fd); + fclose(fd); + return ret; +} + +int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { + DdNode *f[1]; + int ret; + FILE *fd; + f[0] = Cudd_BddToAdd(manager, bdd); + fd = fopen(filename, "w"); + if (fd == NULL) { + perror(filename); + return -1; + } + ret = Cudd_DumpDot(manager, 1, f, varmap.vars, NULL, fd); + fclose(fd); + return ret; +} + +int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { + hisqueue *Nodes; + FILE *outputfile; + int i; + if ((outputfile = fopen(filename, "w")) == NULL) { + perror(filename); + return -1; + } + fprintf(outputfile, "%s\n%i\n%i\n", "@NODES1", varmap.varcnt, varmap.varstart); + Nodes = InitHistory(varmap.varcnt); + for (i = 0; i < varmap.varcnt; i++) + fprintf(outputfile, "%s\t%i\n", varmap.vars[i], Cudd_ReadPerm(manager, i)); + if (bdd == HIGH(manager)) fprintf(outputfile, "TRUE\t0\tTRUE\t0\tTRUE\t0\n"); + else if (bdd == LOW(manager)) fprintf(outputfile, "FALSE\t0\tFALSE\t0\tFALSE\t0\n"); + else SaveExpand(manager, varmap, Nodes, bdd, outputfile); + ReInitHistory(Nodes, varmap.varcnt); + free(Nodes); + fclose(outputfile); + return 0; +} + +void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + int inode; + if (Current != HIGH(manager) && Current != LOW(manager)) { + if ((Found = GetNode(Nodes, varmap.varstart, Current)) == NULL) { + AddNode(Nodes, varmap.varstart, Current, 0.0, 0, NULL); + Found = GetNode(Nodes, varmap.varstart, Current); + } + if (!(Found->ivalue)) { + Found->ivalue = 1; + curnode = GetNodeVarNameDisp(manager, varmap, Current); + inode = GetNodeIndex(Nodes, varmap.varstart, Current); + fprintf(outputfile, "%s\t%i\t", curnode, inode); + h = HighNodeOf(manager, Current); + if (h == HIGH(manager)) { + fprintf(outputfile, "TRUE\t0\t"); + } else if (h == LOW(manager)) { + fprintf(outputfile, "FALSE\t0\t"); + } else { + if (GetNode(Nodes, varmap.varstart, h) == NULL) AddNode(Nodes, varmap.varstart, h, 0.0, 0, NULL); + curnode = GetNodeVarNameDisp(manager, varmap, h); + inode = GetNodeIndex(Nodes, varmap.varstart, h); + fprintf(outputfile, "%s\t%i\t", curnode, inode); + } + l = LowNodeOf(manager, Current); + if (l == HIGH(manager)) { + fprintf(outputfile, "TRUE\t0\n"); + } else if (l == LOW(manager)) { + fprintf(outputfile, "FALSE\t0\n"); + } else { + if (GetNode(Nodes, varmap.varstart, l) == NULL) AddNode(Nodes, varmap.varstart, l, 0.0, 0, NULL); + curnode = GetNodeVarNameDisp(manager, varmap, l); + inode = GetNodeIndex(Nodes, varmap.varstart, l); + fprintf(outputfile, "%s\t%i\n", curnode, inode); + } + SaveExpand(manager, varmap, Nodes, l, outputfile); + SaveExpand(manager, varmap, Nodes, h, outputfile); + } + } +} + +DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile) { + hisqueue *Nodes; + nodeline temp; + DdNode *ret; + int i, pos, *perm; + char *varnam; + perm = (int *) malloc(sizeof(int) * varmap.varcnt); + Nodes = InitHistory(varmap.varcnt); + for (i = 0; i < varmap.varcnt; i++) { + varnam = freadstr(inputfile, "\t"); + pos = atoi(freadstr(inputfile, "\n")); + AddNamedVarAt(varmap, varnam, pos); + perm[pos] = pos; + } + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + ret = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + fclose(inputfile); + ReInitHistory(Nodes, varmap.varcnt); + free(Nodes); + Cudd_Ref(ret); + Cudd_ShuffleHeap(manager, perm); + for (i = 0; i < varmap.varcnt; i++) varmap.ivalue[i] = 0; + return ret; +} + +DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current) { + nodeline temp; + DdNode *newnode, *truenode, *falsenode; + int index; + newnode = GetIfExists(manager, varmap, Nodes, current.varname, current.nodenum); + if (newnode != NULL) return newnode; + falsenode = GetIfExists(manager, varmap, Nodes, current.falsevar, current.falsenode); + if (falsenode == NULL) { + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + falsenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + } + truenode = GetIfExists(manager, varmap, Nodes, current.truevar, current.truenode); + if (truenode == NULL) { + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + truenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + } + index = GetNamedVarIndex(varmap, current.varname); + if (!varmap.ivalue[index]) { + varmap.ivalue[index] = 1; + newnode = GetVar(manager, varmap.varstart + index); + //Cudd_RecursiveDeref(manager, newnode->type.kids.T); + //Cudd_RecursiveDeref(manager, newnode->type.kids.E); + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } else { + if (_RapidLoad == 1) { + newnode = cuddAllocNode(manager); + if (newnode != NULL) { + newnode->index = varmap.varstart + index; + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } + } else { + newnode = cuddUniqueInter(manager, varmap.varstart + index, Cudd_NotCond(truenode, Cudd_IsComplement(truenode)), Cudd_NotCond(falsenode, Cudd_IsComplement(truenode))); + if (newnode != NULL) { + Cudd_Ref(newnode); + } else { + newnode = cuddAllocNode(manager); + if (newnode != NULL) { + newnode->index = varmap.varstart + index; + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } + } + } + } + if (newnode != NULL) { + Nodes[index].thenode[current.nodenum].key = Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); + return Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); + } + return NULL; +} + +DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum) { + int index; + if (strcmp(varname, "TRUE") == 0) return HIGH(manager); + if (strcmp(varname, "FALSE") == 0) return LOW(manager); + index = GetNamedVarIndex(varmap, varname); + if (index == -1 * varmap.varcnt) { + fprintf(stderr, "Error: more variables requested than initialized.\n"); + exit(-1); + } + if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { + index = AddNamedVar(varmap, varname); + } + ExpandNodes(Nodes, index, nodenum); + if (Nodes[index].thenode[nodenum].key != NULL) return Nodes[index].thenode[nodenum].key; + return NULL; +} + +void ExpandNodes(hisqueue *Nodes, int index, int nodenum) { + int i; + if (Nodes[index].cnt > nodenum) return; + Nodes[index].thenode = (hisnode *) realloc(Nodes[index].thenode, (nodenum + 1) * sizeof(hisnode)); + for (i = Nodes[index].cnt; i < nodenum + 1; i++) { + Nodes[index].thenode[i].key = NULL; + Nodes[index].thenode[i].ivalue = 0; + Nodes[index].thenode[i].dvalue = 0.0; + Nodes[index].thenode[i].dynvalue = NULL; + } + Nodes[index].cnt = nodenum + 1; +}; + +int LoadVariableData(namedvars varmap, char *filename) { + FILE *data; + char *dataread, buf, *varname, *dynvalue; + double dvalue = 0.0; + int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; + dynvalue = NULL; + if ((data = fopen(filename, "r")) == NULL) { + perror("fopen"); + return -1; + } + printf("filename %s\n",filename); + dataread = (char *) malloc(sizeof(char) * maxbufsize); + while(!feof(data)) { + index++; + printf("index %d\n",index); + fscanf(data,"@%s\n",dataread); + + varname = (char *) malloc(sizeof(char) * strlen(dataread)); + strcpy(varname, dataread); + varmap.vars[index]=varname; + fscanf(data, "%di\n", &values); + varmap.mvars[index].nVal=values; + varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); + varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); + varmap.mvars[index].booleanVars=(int *)malloc(sizeof(int)*varmap.mvars[index].nBit); + + free(varname); + } + fclose(data); + free(dataread); + return 0; +} + +int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename) { + FILE *data; + char *dataread, buf, *varname, *dynvalue; + double dvalue = 0.0; + int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; + dynvalue = NULL; + if ((data = fopen(filename, "r")) == NULL) { + perror("fopen"); + return -1; + } + dataread = (char *) malloc(sizeof(char) * maxbufsize); + while(!feof(data)) { + index++; + if(fscanf(data,"@%s\n",dataread)<1) break; + varname = (char *) malloc(sizeof(char) * strlen(dataread)); + strcpy(varname, dataread); + varmap.vars[index]=varname; + //printf("vname %d %s\n",index, varmap.vars[index]); + + fscanf(data, "%d\n", &values); + varmap.loaded[index] = 1; + varmap.mvars[index].init=0; + varmap.mvars[index].nVal=values; + varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); + varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); + varmap.mvars[index].booleanVars=(DdNode **)malloc(sizeof(DdNode *)*varmap.mvars[index].nBit); + for (i=0;ivars = (char **) realloc(varmap->vars, sizeof(char *) * newvarcnt); + varmap->loaded = (int *) realloc(varmap->loaded, sizeof(int) * newvarcnt); + varmap->dvalue = (double *) realloc(varmap->dvalue, sizeof(double) * newvarcnt); + varmap->ivalue = (int *) realloc(varmap->ivalue, sizeof(int) * newvarcnt); + varmap->dynvalue = (void **) realloc(varmap->dynvalue, sizeof(int) * newvarcnt); + for (i = varmap->varcnt; i < newvarcnt; i++) { + varmap->vars[i] = NULL; + varmap->loaded[i] = 0; + varmap->dvalue[i] = 0.0; + varmap->ivalue[i] = 0; + varmap->dynvalue[i] = NULL; + } + varmap->varcnt = newvarcnt; +} + +int AddNamedVarAt(namedvars varmap, const char *varname, int index) { + if (varmap.varcnt > index) { + varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); + strcpy(varmap.vars[index], varname); + return index; + } + return -1; +} + +int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int *value) { + + int index,i,l,nBit; + int *booleanVars; + char * vname; + l=strlen(varname); + //printf("addnamed %s\n",varname); + i=0; + while (varname[i]!='-') + { + i++; + } + vname=(char *)malloc(sizeof(char)*(l+1)); + strncpy(vname,varname,i); + vname[i]='\0'; + //printf("addnamed vname %s\n",vname); + sscanf(varname+i+1,"%d",value); + index= GetNamedVarIndex(varmap, vname); + //printf("index %d\n",index); + //printf("init %d\n",varmap.mvars[index].init); + if (index == -1 * varmap.varcnt) { + return -1; + } else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { + index *= -1; + varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); + } + if (varmap.mvars[index].init==0){ + nBit=varmap.mvars[index].nBit; + booleanVars= varmap.mvars[index].booleanVars; + //Cudd_MakeTreeNode(mgr,boolVars,nBit,MTR_FIXED); + for (i=0;ivars[varmap->varcnt - 1] == NULL) + varmap->varcnt--; + return varmap->varcnt; +} + +int all_loaded(namedvars varmap, int disp) { + int i, res = 1; + for (i = 0; i < varmap.varcnt; i++) { + if (varmap.loaded[i] == 0) { + res = 0; + if (disp) fprintf(stderr, "The variable: %s was not loaded with values.\n", varmap.vars[i]); else return 0; + } + } + return res; +} + +/* Parser */ + +DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader) { + int icomment, maxlinesize, icur, iline, curinter, iequal ; + DdNode *Line, **inter; + char buf, *inputline, *filename; + bddfileheader interfileheader; + long startAt, endAt; + double secs; + + // Initialization of intermediate steps + inter = (DdNode **) malloc(sizeof(DdNode *) * fileheader.intercnt); + for (icur = 0; icur < fileheader.intercnt; icur++) inter[icur] = NULL; + // Read file data + interfileheader.inputfile = NULL; + filename = NULL; // For nested files + iequal = 0; // Flag for encountered = sign + icur = 0; // Pointer for inputline buffer location + iline = 5; // Current file line (first after header) + icomment = 0; // Flag for comments + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + while(!feof(fileheader.inputfile)) { + fread(&buf, 1, 1, fileheader.inputfile); + if (buf == ';' || buf == '%' || buf == '$') icomment = 1; + if (buf == '\n') { + if (icomment) icomment = 0; + /* if (iequal > 1) { + fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } else*/ + iequal = 0; + if (icur > 0) { + inputline[icur] = '\0'; + if (inputline[0] != 'L') { + fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + curinter = getInterBDD(inputline); + if (curinter == -1) { + if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { + curinter = atoi(inputline + 1) - 1; + if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { + if (_debug) fprintf(stderr, "Returned: %s\n", inputline); + fclose(fileheader.inputfile); + Line = inter[curinter]; + free(inter); + free(inputline); + return Line; + } else { + fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] == NULL) { + if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); + filename = getFileName(inputline); + if (filename == NULL) { + startAt = clock(); + Line = LineParser(manager, varmap, inter, fileheader.intercnt, inputline, iline); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC)*1000; + //printf("line %e\n",secs); + } else { + interfileheader = ReadFileHeader(filename); + if (interfileheader.inputfile == NULL) { + //Line = simpleBDDload(manager, &varmap, filename); + Line = NULL; + } else { + Line = FileGenerateBDD(manager, varmap, interfileheader); + } + if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); + free(filename); + filename = NULL; + interfileheader.inputfile = NULL; + } + if (Line == NULL) { + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + inter[curinter] = Line; + icur = 0; + } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { + fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } else { + fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } + iline++; + } else if (buf != ' ' && buf != '\t' && !icomment) { + if (buf == '=') iequal++; + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } + fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; +} + + +int getInterBDD(char *function) { + int i, ret; + char *inter; + for (i = 0; i < strlen(function); i++) { + if (function[i] == '=') { + inter = (char *) malloc(sizeof(char) * i); + strncpy(inter, function + 1, i - 1); + inter[i - 1] = '\0'; + if (IsPosNumber(inter)) { + ret = atoi(inter) - 1; + free(inter); + return ret; + } else { + free(inter); + return -1; + } + } + } + return -1; +} + +char* getFileName(const char *function) { + int i = 0; + char *filename; + while(function[i] != '=' && (i + 1) < strlen(function)) i++; + if ((i + 1) < strlen(function)) { + i++; + if (function[i] == '<' && function[strlen(function) - 1] == '>') { + filename = (char *) malloc(sizeof(char) * strlen(function) - i); + strcpy(filename, function + i + 1); + filename[strlen(function) - i - 2] = '\0'; + return filename; + } + } + return NULL; +} + +DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline) { + int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst,value; + long startAt, endAt; + double secs; + DdNode *bdd; + char *term, curoper; + bdd = HIGH(manager); + Cudd_Ref(bdd); + term = NULL; + ivar = -1; + curoper = '*'; + istart = -1; + iend = strlen(function) - 1; + ilength = -1; + symbol = -1; + inegvar = 0; + inegoper = 0; + iconst = 0; + for (i = strlen(function) - 1; i > -1; i--) { + if (symbol == -1 && isOperator(function[i])) { + symbol = i; + istart = i + 1; + ilength = iend - i; + iend = i - 1; + if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { + term = (char *) malloc(sizeof(char) * (ilength + 1)); + strncpy(term, function + istart, ilength); + term[ilength] = '\0'; + } else { + fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); + free(term); + return NULL; + } + } + if (symbol != -1) { + if (term[0] == '~') inegvar = 1; else inegvar = 0; + if (term[0 + inegvar] != 'L') { + // Term is a variable + if (strcmp(term + inegvar, "TRUE") == 0) { + iconst = 1; + } else if (strcmp(term + inegvar, "FALSE") == 0) { + iconst = 1; + inegvar = 1; + } else { + iconst = 0; + //printf("term %s\n",term + inegvar); + ivar = AddNamedMultiVar(manager,varmap, term + inegvar,&value); + //printf("term %s var %d\n",term + inegvar,ivar); + + if (ivar == -1) { + fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); + free(term); + return NULL; + } + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap.varstart)), + Cudd_CountPath(GetVar(manager, ivar + varmap.varstart)), + Cudd_DagSize(GetVar(manager, ivar + varmap.varstart)) ); + startAt = clock(); + if (!iconst) { + if (inegvar) bdd = BDD_Operator(manager, NOT(GetMVar(manager, ivar + varmap.varstart,value,varmap)), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, GetMVar(manager, ivar + varmap.varstart,value,varmap), bdd, curoper, inegoper); + } else { + switch(curoper) { + case '+': + if (inegvar ^ inegoper) ; else { + bdd = HIGH(manager); + Cudd_Ref(bdd); + } + break; + case '*': + if (inegvar ^ inegoper) { + bdd = LOW(manager); + Cudd_Ref(bdd); + } + break; + case '#': + if (inegvar ^ inegoper) ; else bdd = NOT(bdd); + break; + } + } + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } else { + // Term is an intermediate result + if (IsPosNumber(term + inegvar + 1)) + { + ivar = atoi(term + inegvar + 1) - 1; + } + else { + fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); + free(term); + return NULL; + } + if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); + free(term); + return NULL; + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(inter[ivar]), + Cudd_CountPath(inter[ivar]), + Cudd_DagSize(inter[ivar]) ); + startAt = clock(); + if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } + free(term); + term = NULL; + curoper = function[symbol]; + if (curoper == '=') return bdd; + if (function[symbol - 1] == '~') { + inegoper = 1; + i--; + iend--; + } else { + inegoper = 0; + } + symbol = -1; + } + } + return NULL; +} + +DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper) { + switch (Operator) { + case '+': + if (inegoper) return D_BDDNor(manager, bdd1, bdd2); + else return D_BDDOr(manager, bdd1, bdd2); + break; + case '*': + if (inegoper) return D_BDDNand(manager, bdd1, bdd2); + else return D_BDDAnd(manager, bdd1, bdd2); + break; + case '#': + if (inegoper) return D_BDDXnor(manager, bdd1, bdd2); + else return D_BDDXor(manager, bdd1, bdd2); + break; + default: + return NULL; + break; + } +} + +DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap) { + int icomment, maxlinesize, icur, iline, curinter, iequal, iinters, itmp, i; + DdNode *Line, **inter; + char buf, *inputline, *filename; + bddfileheader interfileheader; + // Initialization of intermediate steps + iinters = 1; + inter = (DdNode **) malloc(sizeof(DdNode *) * iinters); + for (icur = 0; icur < iinters; icur++) inter[icur] = NULL; + // Read file data + interfileheader.inputfile = NULL; + filename = NULL; // For nested files + iequal = 0; // Flag for encountered = sign + icur = 0; // Pointer for inputline buffer location + iline = 1; // Current file line (first after header) + icomment = 0; // Flag for comments + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + + do { + buf = fgetc(stdin); + if (buf == ';' || buf == '%' || buf == '$') icomment = 1; + if (buf == '\n') { + if (icomment) icomment = 0; + if (iequal > 1) { + fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); + free(inter); + free(inputline); + return NULL; + } else iequal = 0; + if (icur > 0) { + inputline[icur] = '\0'; + if (inputline[0] == '@') { + if (inputline[1] == 'e') { + free(inter); + free(inputline); + exit(0); + } else { + itmp = GetParam(inputline, 1); + if (itmp > varmap->varcnt) + EnlargeNamedVars(varmap, itmp); + itmp = GetParam(inputline, 2); + if (itmp > iinters) { + inter = (DdNode **) realloc(inter, sizeof(DdNode *) * itmp); + for (i = iinters; i < itmp; i++) inter[i] = NULL; + iinters = itmp; + } + } + icur = 0; + } else { + if (inputline[0] != 'L') { + fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); + free(inter); + free(inputline); + return NULL; + } + curinter = getInterBDD(inputline); + if (curinter == -1) { + if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { + curinter = atoi(inputline + 1) - 1; + if (curinter > -1 && curinter < iinters && inter[curinter] != NULL) { + if (_debug) fprintf(stderr, "Returned: %s\n", inputline); + Line = inter[curinter]; + free(inter); + free(inputline); + return Line; + } else { + fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else if (curinter > -1) { + if (curinter >= iinters) { + inter = (DdNode **) realloc(inter, sizeof(DdNode *) * (curinter + 1)); + for (i = iinters; i < curinter + 1; i++) inter[i] = NULL; + iinters = curinter + 1; + } + if (inter[curinter] == NULL) { + if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); + filename = getFileName(inputline); + if (filename == NULL) { + Line = OnlineLineParser(manager, varmap, inter, iinters, inputline, iline); + } else { + interfileheader = ReadFileHeader(filename); + if (interfileheader.inputfile == NULL) { + //Line = simpleBDDload(manager, varmap, filename); + Line = NULL; + } else { + Line = FileGenerateBDD(manager, *varmap, interfileheader); + } + if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); + free(filename); + filename = NULL; + interfileheader.inputfile = NULL; + } + if (Line == NULL) { + free(inter); + free(inputline); + return NULL; + } + inter[curinter] = Line; + icur = 0; + } else if (inter[curinter] != NULL) { + fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } + } + iline++; + } else if (buf != ' ' && buf != '\t' && !icomment) { + if (buf == '=') iequal++; + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + free(inter); + free(inputline); + return NULL; + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } while(1); + fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); + free(inter); + free(inputline); + return NULL; +} + +DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline) { + int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst; + long startAt, endAt; + double secs; + DdNode *bdd; + char *term, curoper; + bdd = HIGH(manager); + Cudd_Ref(bdd); + term = NULL; + ivar = -1; + curoper = '*'; + istart = -1; + iend = strlen(function) - 1; + ilength = -1; + symbol = -1; + inegvar = 0; + inegoper = 0; + iconst = 0; + for (i = strlen(function) - 1; i > -1; i--) { + if (symbol == -1 && isOperator(function[i])) { + symbol = i; + istart = i + 1; + ilength = iend - i; + iend = i - 1; + if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { + term = (char *) malloc(sizeof(char) * (ilength + 1)); + strncpy(term, function + istart, ilength); + term[ilength] = '\0'; + } else { + fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); + free(term); + return NULL; + } + } + if (symbol != -1) { + if (term[0] == '~') inegvar = 1; else inegvar = 0; + if (term[0 + inegvar] != 'L') { + // Term is a variable + if (strcmp(term , "TRUE") == 0) { + iconst = 1; + } else if (strcmp(term , "FALSE") == 0) { + iconst = 1; + inegvar = 1; + } else { + iconst = 0; + ivar = AddNamedVar(*varmap, term + inegvar); + if (ivar == -1) { + EnlargeNamedVars(varmap, varmap->varcnt + 1); + ivar = AddNamedVar(*varmap, term + inegvar); + } + if (ivar == -1) { + fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); + free(term); + return NULL; + } + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap->varstart)), + Cudd_CountPath(GetVar(manager, ivar + varmap->varstart)), + Cudd_DagSize(GetVar(manager, ivar + varmap->varstart)) ); + startAt = clock(); + if (!iconst) { + if (inegvar) bdd = BDD_Operator(manager, NOT(GetVar(manager, ivar + varmap->varstart)), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, GetVar(manager, ivar + varmap->varstart), bdd, curoper, inegoper); + } else { + switch(curoper) { + case '+': + if (inegvar ^ inegoper) ; else { + bdd = HIGH(manager); + Cudd_Ref(bdd); + } + break; + case '*': + if (inegvar ^ inegoper) { + bdd = LOW(manager); + Cudd_Ref(bdd); + } + break; + case '#': + if (inegvar ^ inegoper) ; else bdd = NOT(bdd); + break; + } + } + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } else { + // Term is an intermediate result + if (IsPosNumber(term + inegvar + 1)) ivar = atoi(term + inegvar + 1) - 1; else { + fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); + free(term); + return NULL; + } + if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); + free(term); + return NULL; + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(inter[ivar]), + Cudd_CountPath(inter[ivar]), + Cudd_DagSize(inter[ivar]) ); + startAt = clock(); + if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } + free(term); + term = NULL; + curoper = function[symbol]; + if (curoper == '=') return bdd; + if (function[symbol - 1] == '~') { + inegoper = 1; + i--; + iend--; + } else { + inegoper = 0; + } + symbol = -1; + } + } + return NULL; +} + +int GetParam(char *inputline, int iParam) { + int icoma, istart, iend, ret; + char *numb; + istart = 1; + icoma = istart; + iend = strlen(inputline); + while((inputline[icoma] != ',') && (icoma < iend)) + icoma++; + if (iParam == 1) { + numb = (char *) malloc(sizeof(char) * icoma); + strncpy(numb, inputline + 1, icoma - 1); + numb[icoma - 1] = '\0'; + if (IsPosNumber(numb)) { + ret = atoi(numb); + free(numb); + return ret; + } + } else if(iParam == 2) { + numb = (char *) malloc(sizeof(char) * (iend - icoma + 1)); + strncpy(numb, inputline + icoma + 1, iend - icoma); + numb[iend - icoma] = '\0'; + if (IsPosNumber(numb)) { + ret = atoi(numb); + free(numb); + return ret; + } + } + return 0; +} + +void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd) { + char buf, *inputline; + int icur, maxlinesize, iline, index, iloop, ivalue, iQsize, i, inQ; + double dvalue; + DdNode **Q, **Q2, *h_node, *l_node, *curnode; + hisqueue *his; + hisnode *hnode; + iloop = 1; + icur = 0; // Pointer for inputline buffer location + iline = 1; // Current file line (first after header) + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + curnode = bdd; + iQsize = 0; + Q = (DdNode **) malloc(sizeof(DdNode *) * iQsize); + Q2 = NULL; + his = InitHistory(varmap.varcnt); + do { + buf = fgetc(stdin); + if (buf == '\n') { + inputline[icur] = '\0'; + if ((icur > 0) && (inputline[0] == '@') && (inputline[2] == ',' || inputline[2] == '\0')) { + switch(inputline[1]) { + case 'c': + printf("bdd_temp_value('%s', %i).\n", GetNodeVarNameDisp(manager, varmap, curnode), iQsize); + break; + case 'n': + if (curnode != HIGH(manager) && curnode != LOW(manager) && (hnode = GetNode(his, varmap.varstart, curnode)) == NULL) { + AddNode(his, varmap.varstart, curnode, 0.0, 0, NULL); + l_node = LowNodeOf(manager, curnode); + h_node = HighNodeOf(manager, curnode); + inQ = 0; + for(i = 0; (i < iQsize / 2) && (inQ < 3); i++) + inQ = (Q[i] == l_node) || (Q[iQsize - i] == l_node) + 2 * (Q[i] == h_node) || (Q[iQsize - i] == h_node); + if (inQ & 1 == 0) inQ = inQ + (GetNode(his, varmap.varstart, l_node) != NULL); + if (inQ & 2 == 0) inQ = inQ + 2 * (GetNode(his, varmap.varstart, h_node) != NULL); + if (inQ & 1 == 1) inQ = inQ - (l_node == HIGH(manager) || l_node == LOW(manager)); + if (inQ & 2 == 2) inQ = inQ - 2 * (h_node == HIGH(manager) || h_node == LOW(manager)); + switch(inQ) { + case 0: + iQsize += 2; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 2] = l_node; + Q[iQsize - 1] = h_node; + break; + case 1: + iQsize++; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 1] = h_node; + break; + case 2: + iQsize++; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 1] = l_node; + break; + case 3: + break; + default: + break; + } + } + if (inputline[2] == '\0' || strcmp(inputline + 3, "DFS") == 0) { + if (iQsize > 0) { + iQsize--; + curnode = Q[iQsize]; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + } + } else if (strcmp(inputline + 3, "BFS") == 0) { + if (iQsize > 0) { + iQsize--; + curnode = Q[0]; + Q2 = (DdNode **) malloc(sizeof(DdNode *) * iQsize); + for(i = 0; i < iQsize; i++) + Q2[i] = Q[i + 1]; + free(Q); + Q = Q2; + } + } else { + fprintf(stderr, "Error: Could not find method: %s, Correct syntax @n,[DFS, BFS].\n", inputline + 3); + free(Q); + free(inputline); + exit(-1); + } + break; + case 'h': + printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, HighNodeOf(manager, curnode))); + break; + case 'l': + printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, LowNodeOf(manager, curnode))); + break; + case 'v': + index = GetNamedVarIndex(varmap, inputline + 3); + if (index >= 0) { + fprintf(stdout, "bdd_temp_value([%f,%i,%s]).\n", varmap.dvalue[index], varmap.ivalue[index], (char *) varmap.dynvalue[index]); + } else { + fprintf(stderr, "Error: Could not find variable: %s, Correct syntax @v,[variable name].\n", inputline + 3); + free(Q); + free(inputline); + exit(-1); + } + break; + case 'e': + iloop = 0; + break; + default: + fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); + free(Q); + free(inputline); + exit(-1); + break; + } + icur = 0; + } else { + fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); + free(Q); + free(inputline); + exit(-1); + } + iline++; + } else if (buf != ' ' && buf != '\t') { + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + free(Q); + free(inputline); + exit(-1); + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } while(iloop); + free(Q); + free(inputline); +} + +DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap) +{ + + int i; + int bit,*booleanVars,booleanVar; + variable v; + DdNode * node, * tmp; + + + v=varmap.mvars[varIndex]; + booleanVars=v.booleanVars; + i=v.nBit-1; + booleanVar=booleanVars[i]; + bit=value & 01; + if (bit) + { + node=Cudd_bddIthVar(mgr, booleanVar); + } + else + { + node=Cudd_Not(Cudd_bddIthVar(mgr, booleanVar)); + } + value=value>>1; + i--; + + while (i>=0) { + booleanVar=booleanVars[i]; + bit=value & 01; + if (bit) + { + tmp=Cudd_bddAnd(mgr,node,Cudd_bddIthVar(mgr, booleanVar)); + Cudd_Ref(tmp); + } + else + { + tmp=Cudd_bddAnd(mgr,node,Cudd_Not(Cudd_bddIthVar(mgr, booleanVar))); + Cudd_Ref(tmp); + } + value=value>>1; + i--; + Cudd_RecursiveDeref(mgr,node); + node=tmp; + } +return node; +} + + + diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base new file mode 100644 index 000000000..998ad182b --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base @@ -0,0 +1,306 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: simplecudd.h * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include +#include +#include +#include +#include +#include "util.h" +#include "cudd.h" +#include "cuddInt.h" +#include "general.h" + +#define IsHigh(manager, node) HIGH(manager) == node +#define IsLow(manager, node) LOW(manager) == node +#define HIGH(manager) Cudd_ReadOne(manager) +#define LOW(manager) Cudd_Not(Cudd_ReadOne(manager)) +#define NOT(node) Cudd_Not(node) +#define GetIndex(node) Cudd_NodeReadIndex(node) +#define GetMVar(manager, index, value, varmap) equality(manager,index,value,varmap)//Cudd_bddIthVar(manager, index) +#define GetVar(manager, index) Cudd_bddIthVar(manager, index) +#define NewVar(manager) Cudd_bddNewVar(manager) +#define KillBDD(manager) Cudd_Quit(manager) +#define GetVarCount(manager) Cudd_ReadSize(manager) +#define DEBUGON _debug = 1 +#define DEBUGOFF _debug = 0 +#define RAPIDLOADON _RapidLoad = 1 +#define RAPIDLOADOFF _RapidLoad = 0 +#define SETMAXBUFSIZE(size) _maxbufsize = size +#define BDDFILE_ERROR -1 +#define BDDFILE_OTHER 0 +#define BDDFILE_SCRIPT 1 +#define BDDFILE_NODEDUMP 2 + +extern int _RapidLoad; +extern int _debug; +extern int _maxbufsize; + +typedef struct _bddfileheader { + FILE *inputfile; + int version; + int varcnt; + int bvarcnt; + int varstart; + int intercnt; + int filetype; +} bddfileheader; + +typedef struct + { +int nVal,nBit,init; +double * probabilities; +int * booleanVars; +} variable; + +typedef struct _namedvars { + int varcnt; + int varstart; + char **vars; + int *loaded; + double *dvalue; + int *ivalue; + void **dynvalue; + variable * mvars; + int * bVar2mVar; +} namedvars; + + +typedef struct _hisnode { + DdNode *key; + double dvalue; + int ivalue; + void *dynvalue; +} hisnode; + +typedef struct _hisqueue { + int cnt; + hisnode *thenode; +} hisqueue; + +typedef struct _nodeline { + char *varname; + char *truevar; + char *falsevar; + int nodenum; + int truenode; + int falsenode; +} nodeline; + +/* Initialization */ + +DdManager* simpleBDDinit(int varcnt); + +/* BDD Generation */ + +DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); + +DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader); +DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap); +DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline); +DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline); +DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper); +int getInterBDD(char *function); +char* getFileName(const char *function); +int GetParam(char *inputline, int iParam); +int LoadVariableData(namedvars varmap, char *filename); +int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename); + +/* Named variables */ + +namedvars InitNamedVars(int varcnt, int varstart); +namedvars InitNamedMultiVars(int varcnt, int varstart, int bvarcnt); +void EnlargeNamedVars(namedvars *varmap, int newvarcnt); +int AddNamedVarAt(namedvars varmap, const char *varname, int index); +int AddNamedVar(namedvars varmap, const char *varname); +int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varnamei, int *value); +void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue, void *dynvalue); +int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue, int ivalue, void *dynvalue); +int GetNamedVarIndex(const namedvars varmap, const char *varname); +int RepairVarcnt(namedvars *varmap); +char* GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node); +char* GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node); +int all_loaded(namedvars varmap, int disp); + +/* Traversal */ + +DdNode* HighNodeOf(DdManager *manager, DdNode *node); +DdNode* LowNodeOf(DdManager *manager, DdNode *node); + +/* Traversal - History */ + +hisqueue* InitHistory(int varcnt); +void ReInitHistory(hisqueue *HisQueue, int varcnt); +void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); +hisnode* GetNode(hisqueue *HisQueue, int varstart, DdNode *node); +int GetNodeIndex(hisqueue *HisQueue, int varstart, DdNode *node); +void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd); + +/* Save-load */ + +bddfileheader ReadFileHeader(char *filename); +int CheckFileVersion(const char *version); + +DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile); +DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current); +DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum); + +int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); +void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile); +void ExpandNodes(hisqueue *Nodes, int index, int nodenum); + +/* Export */ + +int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename); +int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); + +DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap); +hisnode* GetNodei1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); +void AddNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); +hisnode* GetNode1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); diff --git a/packages/cplint/approx/simplecuddLPADs/Makefile.in b/packages/cplint/approx/simplecuddLPADs/Makefile.in new file mode 100644 index 000000000..e5e37074d --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/Makefile.in @@ -0,0 +1,54 @@ +# +# default base directory for YAP installation +# (EROOT for architecture-dependent files) +# +prefix = @prefix@ +ROOTDIR = $(prefix) +EROOTDIR = ${prefix} +# +# where the binary should be +# +BINDIR = $(EROOTDIR)/bin +# +# where YAP should look for libraries +# +LIBDIR=$(EROOTDIR)/lib/Yap +DESTDIR=$(prefix)/share/Yap +# +# +CC=@CC@ +# +# +# You shouldn't need to change what follows. +# +INSTALL=@INSTALL@ +INSTALL_DATA=@INSTALL_DATA@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +SHELL=/bin/sh +RANLIB=ranlib +SHLIB_CFLAGS=-shared -fPIC +SHLIB_SUFFIX=.so +CWD=$(PWD) +srcdir=@srcdir@ +CPLINT_CFLAGS=@CPLINT_CFLAGS@ +CPLINT_LDFLAGS=@CPLINT_LDFLAGS@ +CPLINT_LIBS=@CPLINT_LIBS@ + +# + + +default: LPADBDD + +LPADBDD: ProblogBDD.o simplecudd.o general.o + @echo Making ProblogBDD... + @echo Copyright T. Mantadelis, A. Kimmig, B. Gutmann and Katholieke Universiteit Leuven 2008 + $(CC) $(CPLINT_LDFLAGS) ProblogBDD.o simplecudd.o general.o $(CPLINT_LIBS) -o LPADBDD + +%.o : $(srcdir)/%.c + $(CC) $(CPLINT_CFLAGS) -c $< + +clean: + rm -f *.o LPADBDD + +install: default + $(INSTALL_PROGRAM) LPADBDD $(DESTDIR) diff --git a/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c b/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c new file mode 100644 index 000000000..269ae533d --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c @@ -0,0 +1,871 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * +* and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * +* File: ProblogBDD.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" +#include +#include + +typedef struct _parameters { + int loadfile; + int savedfile; + int exportfile; + int inputfile; + int debug; + int errorcnt; + int *error; + int method; + int queryid; + int timeout; + double sigmoid_slope; + int online; + int maxbufsize; + char *ppid; +} parameters; + +typedef struct _gradientpair { + double probability; + double gradient; +} gradientpair; + +typedef struct _extmanager { + DdManager *manager; + DdNode *t, *f; + hisqueue *his; + namedvars varmap; +} extmanager; + + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); +double Prob(extmanager MyManager, DdNode *node, int comp); +int correctPosition(int index,variable v,int posBVar); +double ret_prob(extmanager MyManager, DdNode * bdd); + + + +int argtype(const char *arg); +void printhelp(int argc, char **arg); +parameters loadparam(int argc, char **arg); +parameters params; + +void handler(int num); +void pidhandler(int num); +void termhandler(int num); + +double sigmoid(double x, double slope); +void myexpand(extmanager MyManager, DdNode *Current); +double CalcProbability(extmanager MyManager, DdNode *Current); +double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); +int patterncalculated(char *pattern, extmanager MyManager, int loc); +char * extractpattern(char *thestr); + +int main(int argc, char **arg) { + clock_t start, endc, endt; + double elapsedc,elapsedt; + + extmanager MyManager; + DdNode *bdd; + bddfileheader fileheader; + int i, ivarcnt, code; + gradientpair tvalue; + double probability = -1.0; + char *varpattern; + varpattern = NULL; + code = -1; + params = loadparam(argc, arg); + if (params.errorcnt > 0) { + printhelp(argc, arg); + for (i = 0; i < params.errorcnt; i++) { + fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); + } + return -1; + } + + if (params.online == 0 && params.loadfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: you must specify a loading file.\n"); + return -1; + } + + if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { + printhelp(argc, arg); + fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); + return -1; + } + + if (params.debug) DEBUGON; + RAPIDLOADON; + SETMAXBUFSIZE(params.maxbufsize); + + signal(SIGINT, termhandler); + if (params.ppid != NULL) { + signal(SIGALRM, pidhandler); + alarm(5); + } else { + signal(SIGALRM, handler); + alarm(params.timeout); + } + if (params.online) { + MyManager.manager = simpleBDDinit(0); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(1, 0); + bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); + ivarcnt = GetVarCount(MyManager.manager); + } else { + fileheader = ReadFileHeader(arg[params.loadfile]); + switch(fileheader.filetype) { + case BDDFILE_SCRIPT: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); + if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; + start = clock(); + bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); + endc=clock(); + elapsedc = ((double) (endc - start)) / CLOCKS_PER_SEC; + printf("elapsed_construction(%lf).\n",elapsedc); + ivarcnt = fileheader.varcnt; + break; + case BDDFILE_NODEDUMP: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); + bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); + ivarcnt = fileheader.varcnt; + break; + default: + fprintf(stderr, "Error: not a valid file format to load.\n"); + return -1; + break; + } + } + alarm(0); + + // problem specifics + + if (bdd != NULL) { + ivarcnt = RepairVarcnt(&MyManager.varmap); + code = 0; + /* + if (params.inputfile != -1) { + if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; + if (!all_loaded(MyManager.varmap, 1)) return -1; + }*/ + MyManager.his = InitHistory(ivarcnt); + if (params.method != 0) { + switch(arg[params.method][0]) { + case 'g': + for (i = 0; i < MyManager.varmap.varcnt; i++) { + if (MyManager.varmap.vars[i] != NULL) { + varpattern = extractpattern(MyManager.varmap.vars[i]); + if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { + tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); + probability = tvalue.probability; + double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; + if (varpattern == NULL) { + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); + } else { + varpattern[strlen(varpattern) - 2] = '\0'; + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); + } + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + } + if (varpattern != NULL) free(varpattern); + } else { + fprintf(stderr, "Error: no variable name given for parameter.\n"); + } + } + if (probability < 0.0) { + // no nodes, so we have to calculate probability ourself + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + } + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'l': + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'p': + printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); + break; + case 'o': + onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); + break; + default: + myexpand(MyManager, bdd); + break; + } + } else { + start=clock(); + // simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); + printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); + endt=clock(); + elapsedt = ((double) (endt - start)) / CLOCKS_PER_SEC; + printf("elapsed_traversing(%lf).\n",elapsedt); +// myexpand(MyManager, bdd); + } + if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); + if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + free(MyManager.his); + } + if (MyManager.manager != NULL) { + KillBDD(MyManager.manager); +exit(code); + free(MyManager.varmap.dvalue); + free(MyManager.varmap.ivalue); + free(MyManager.varmap.dynvalue); + for (i = 0; i < MyManager.varmap.varcnt; i++) + { + free(MyManager.varmap.vars[i]); + free(MyManager.varmap.mvars[i].probabilities); + free(MyManager.varmap.mvars[i].booleanVars); + } + free(MyManager.varmap.vars); + free(MyManager.varmap.mvars); + free(MyManager.varmap.bVar2mVar); + } + if (params.error != NULL) free(params.error); + + return code; + +} + +/* Shell Parameters handling */ + +int argtype(const char *arg) { + if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; + if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; + if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; + if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; + if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; + if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; + if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; + if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; + if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; + if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; + if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; + if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; + return -1; +} + +void printhelp(int argc, char **arg) { + fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); + fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); + fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); + fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); + fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); + fprintf(stderr, "Optional parameters:\n"); + fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); + fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); + fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); + fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); + fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); + fprintf(stderr, "Extra parameters:\n"); + fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); + fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); + fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); + fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); + fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); + fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); +} + +parameters loadparam(int argc, char **arg) { + int i; + parameters params; + params.loadfile = -1; + params.savedfile = -1; + params.exportfile = -1; + params.method = 0; + params.inputfile = -1; + params.debug = 0; + params.errorcnt = 0; + params.queryid = 0; + params.timeout = 0; + params.sigmoid_slope = 1.0; + params.online = 0; + params.maxbufsize = 0; + params.ppid = NULL; + params.error = (int *) malloc(argc * sizeof(int)); + for (i = 1; i < argc; i++) { + switch(argtype(arg[i])) { + case 0: + if (argc > i + 1) { + i++; + params.loadfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 2: + if (argc > i + 1) { + i++; + params.exportfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 3: + if (argc > i + 1) { + i++; + params.method = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 4: + if (argc > i + 1) { + i++; + params.inputfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 5: + printhelp(argc, arg); + break; + case 6: + params.debug = 1; + break; + case 7: + if (argc > i + 1) { + i++; + params.queryid = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 8: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.timeout = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 9: + if (argc > i + 1) { + i++; + params.savedfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 10: + if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { + i++; + params.sigmoid_slope = atof(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 11: + params.online = 1; + break; + case 12: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.maxbufsize = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 13: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); + strcpy(params.ppid, arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + default: + params.error[params.errorcnt] = i; + params.errorcnt++; + break; + } + } + return params; +} + +/* Error Handlers */ + +void handler(int num) { + fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); + exit(-1); +} + +void pidhandler(int num) { + char *s; + if (params.timeout > 0) { + params.timeout -= 5; + if (params.timeout <= 0) { + fprintf(stderr, "Error: Timeout exceeded.\n"); + exit(-1); + } + } + s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); + strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); + if (system(s) != 0) exit(4); + signal(SIGALRM, pidhandler); + alarm(5); + free(s); +} + +void termhandler(int num) { + exit(3); +} + +/* General Functions */ + +double sigmoid(double x, double slope) { + return 1 / (1 + exp(-x * slope)); +} + +/* Debugging traverse function */ + +void myexpand(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + printf("%s\n", curnode); + if ((Current != MyManager.t) && (Current != MyManager.f) && + ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + printf("l(%s)->", curnode); + myexpand(MyManager, l); + printf("h(%s)->", curnode); + myexpand(MyManager, h); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); + } +} + +/* Angelikas Algorithm */ + +double CalcProbability(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + double lvalue, hvalue, tvalue; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) return 1.0; + if (Current == MyManager.f) return 0.0; + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcProbability(MyManager, l); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcProbability(MyManager, h); + tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; + tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); + return tvalue; +} + +/* Bernds Algorithm */ + +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + gradientpair lvalue, hvalue, tvalue; + double this_probability; + double *gradient; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) { + tvalue.probability = 1.0; + tvalue.gradient = 0.0; + return tvalue; + } + if (Current == MyManager.f) { + tvalue.probability = 0.0; + tvalue.gradient = 0.0; + return tvalue; + } + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { + tvalue.probability = Found->dvalue; + tvalue.gradient = *((double *) Found->dynvalue); + return tvalue; + } + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); + this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); + tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; + tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; + if ((GetIndex(Current) == TargetVar) || + ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { + tvalue.gradient += hvalue.probability - lvalue.probability; + } + gradient = (double *) malloc(sizeof(double)); + *gradient = tvalue.gradient; + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); + return tvalue; +} + +char * extractpattern(char *thestr) { + char *p; + int i = 0, sl = strlen(thestr); + while((thestr[i] != '_') && (i < sl)) i++; + if (i == sl) return NULL; + i++; + p = (char *) malloc(sizeof(char) * (i + 2)); + strncpy(p, thestr, i); + p[i] = '*'; + p[i + 1] = '\0'; + return p; +} + +int patterncalculated(char *pattern, extmanager MyManager, int loc) { + int i; + if (pattern == NULL) return 0; + for (i = loc - 1; i > -1; i--) + if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; + return 0; +} + +double Prob(extmanager MyManager, DdNode *node, int comp) +/* compute the probability of the expression rooted at node +nodes is used to store nodes for which the probability has alread been computed +so that it is not recomputed + */ +{ + int mVarIndex,nBit,index; + variable v; + hisnode *Found; + double res; + double value; + + + //printf("Prob node %d\n",node); + //index=Cudd_NodeReadIndex(node); + //printf("Prob INdex %d\n",index); + if (Cudd_IsConstant(node)) + { + value=Cudd_V(node);//node->type.value; + //printf("Value %e comp %d\n",value,comp); + if (comp)//Cudd_IsComplement(node)) + //return (1.0-value); + //if (value>0) + { +// printf("return 0"); + return 0.0; + } + else + { +// printf("return 1"); + return 1.0; + } +/*else + if (value>0) + return 1.0; + else + return 0.0; +*/ //return value; + } + else +{ + Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); + + if (Found!=NULL) + { + //printf("value found %e\n",Found->dvalue); + return Found->dvalue; + } + else + { + index=Cudd_NodeReadIndex(node); + //printf("node absent %d comp %d\n",node,comp); + //mVarIndex=array_fetch(int,bVar2mVar,index); + mVarIndex=MyManager.varmap.bVar2mVar[index]; + //v=array_fetch(variable,vars,mVarIndex); + v=MyManager.varmap.mvars[mVarIndex]; + nBit=v.nBit; +// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); + //scanf("%d",&r); + res=ProbBool(MyManager,node,0,nBit,0,v,comp); + //printf("New val %e\n",res); + AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); + return res; + } +} +} + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) +/* explores a group of binary variables making up the multivalued variable v */ +{ + DdNode *T,*F; + double p,res; + double * probs; + int index; +// printf("ProbBool nBit %d\n",nBit); + //scanf("%d",&r); + probs=v.probabilities; + if (nBit==0) + { + //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); +// printf("bits %d v.nbit %d\n",bits,v.nBit); + if (bits>=v.nVal) + //if (comp) + { + //printf("bits>=v.nbit return 0\n"); + return 0.0; + } + //else + //{printf("return 0\n"); + //return 1.0;}} + else + { + // printf("Val %d\n",bits); + + //p=array_fetch(double,probs,bits); + p=probs[bits]; + //printf("prob %e\n",p); + res=p*Prob(MyManager,node,comp); + //printf("prob %e\n",p); + //printf("bottom %e\n",res); + return res; + } + } + else + { + //if (correctPosition(node->index,v,node,posBVar)) + index=Cudd_NodeReadIndex(node); + //printf("index %d\n",Cudd_NodeReadIndex(node)); + if (correctPosition(index,v,posBVar)) + { + //printf("node %d\n",node); + T = Cudd_T(node);//node->type.kids.T; + F = Cudd_E(node);//node->type.kids.E; + bits=bits<<1; + //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); + res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); + //printf("comp %d ",comp); + comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); + //printf("comp %d \n",comp); +res=res+ + ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); + //printf("res 2 %e\n",res); + return res; + } + else + { + //printf("absent var\n"); + bits=bits<<1; + // printf("Var =1\n"); + res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res 1 %e\n",res); +//printf("var =0\n"); + res=res+ + ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); + // printf("res 2 %e\n",res); +return res; + } + } +} + +int correctPosition(int index,variable v,int posBVar) +/* returns 1 is the boolean variable with index posBVar is in the correct position +currently explored by ProbBool */ +{ + int bvar; +//printf("posbvar %d\n",posBVar); +//printf("length %d\n",array_n(v.booleanVars)); + //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); + bvar=v.booleanVars[posBVar]; + + // return var->index==index; +return(bvar==index); +} + +double ret_prob(extmanager MyManager, DdNode * bdd) +{ + double prob; + /* dividend is a global variable used by my_hash + it is equal to an unsigned int with binary representation 11..1 */ + prob=Prob(MyManager,bdd,Cudd_IsComplement(bdd)); + + return prob; + +} diff --git a/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c b/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c new file mode 100644 index 000000000..a799895bc --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c @@ -0,0 +1,895 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * +* and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * +* File: ProblogBDD.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" +#include + +typedef struct _parameters { + int loadfile; + int savedfile; + int exportfile; + int inputfile; + int debug; + int errorcnt; + int *error; + int method; + int queryid; + int timeout; + double sigmoid_slope; + int online; + int maxbufsize; + char *ppid; +} parameters; + +typedef struct _gradientpair { + double probability; + double gradient; +} gradientpair; + +typedef struct _extmanager { + DdManager *manager; + DdNode *t, *f; + hisqueue *his; + namedvars varmap; +} extmanager; + +GHashTable * nodes; /* hash table that associates nodes with their probability if already + computed, it is defined in glib */ +unsigned long dividend; + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); +double Prob(extmanager MyManager, DdNode *node, int comp); +int correctPosition(int index,variable v, DdNode * node,int posBVar); +gint my_equal(gconstpointer v,gconstpointer v2); +guint my_hash(gconstpointer key); +void dealloc(gpointer key,gpointer value,gpointer user_data); +double ret_prob(extmanager MyManager, DdNode * bdd); + + + +int argtype(const char *arg); +void printhelp(int argc, char **arg); +parameters loadparam(int argc, char **arg); +parameters params; + +void handler(int num); +void pidhandler(int num); +void termhandler(int num); + +double sigmoid(double x, double slope); +void myexpand(extmanager MyManager, DdNode *Current); +double CalcProbability(extmanager MyManager, DdNode *Current); +double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); +int patterncalculated(char *pattern, extmanager MyManager, int loc); +char * extractpattern(char *thestr); + +int main(int argc, char **arg) { + extmanager MyManager; + DdNode *bdd; + bddfileheader fileheader; + int i, ivarcnt, code; + gradientpair tvalue; + double probability = -1.0; + char *varpattern; + varpattern = NULL; + code = -1; + params = loadparam(argc, arg); + if (params.errorcnt > 0) { + printhelp(argc, arg); + for (i = 0; i < params.errorcnt; i++) { + fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); + } + return -1; + } + + if (params.online == 0 && params.loadfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: you must specify a loading file.\n"); + return -1; + } + + if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { + printhelp(argc, arg); + fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); + return -1; + } + + if (params.debug) DEBUGON; + RAPIDLOADON; + SETMAXBUFSIZE(params.maxbufsize); + + signal(SIGINT, termhandler); + if (params.ppid != NULL) { + signal(SIGALRM, pidhandler); + alarm(5); + } else { + signal(SIGALRM, handler); + alarm(params.timeout); + } + if (params.online) { + MyManager.manager = simpleBDDinit(0); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(1, 0); + bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); + ivarcnt = GetVarCount(MyManager.manager); + } else { + fileheader = ReadFileHeader(arg[params.loadfile]); + switch(fileheader.filetype) { + case BDDFILE_SCRIPT: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); + if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; + bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); + ivarcnt = fileheader.varcnt; + break; + case BDDFILE_NODEDUMP: + if (params.inputfile == -1) { + printhelp(argc, arg); + fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); + return -1; + } + MyManager.manager = simpleBDDinit(fileheader.varcnt); + MyManager.t = HIGH(MyManager.manager); + MyManager.f = LOW(MyManager.manager); + MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); + bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); + ivarcnt = fileheader.varcnt; + break; + default: + fprintf(stderr, "Error: not a valid file format to load.\n"); + return -1; + break; + } + } + alarm(0); + + // problem specifics + + if (bdd != NULL) { + ivarcnt = RepairVarcnt(&MyManager.varmap); + code = 0; + /* + if (params.inputfile != -1) { + if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; + if (!all_loaded(MyManager.varmap, 1)) return -1; + }*/ + MyManager.his = InitHistory(ivarcnt); + if (params.method != 0) { + switch(arg[params.method][0]) { + case 'g': + for (i = 0; i < MyManager.varmap.varcnt; i++) { + if (MyManager.varmap.vars[i] != NULL) { + varpattern = extractpattern(MyManager.varmap.vars[i]); + if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { + tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); + probability = tvalue.probability; + double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; + if (varpattern == NULL) { + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); + } else { + varpattern[strlen(varpattern) - 2] = '\0'; + printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); + } + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + } + if (varpattern != NULL) free(varpattern); + } else { + fprintf(stderr, "Error: no variable name given for parameter.\n"); + } + } + if (probability < 0.0) { + // no nodes, so we have to calculate probability ourself + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + } + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'l': + tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); + probability = tvalue.probability; + printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); + break; + case 'p': + printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); + break; + case 'o': + onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); + break; + default: + myexpand(MyManager, bdd); + break; + } + } else { + //simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); + printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); +// myexpand(MyManager, bdd); + } + if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); + if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); + ReInitHistory(MyManager.his, MyManager.varmap.varcnt); + free(MyManager.his); + } + if (MyManager.manager != NULL) { + KillBDD(MyManager.manager); + free(MyManager.varmap.dvalue); + free(MyManager.varmap.ivalue); + free(MyManager.varmap.dynvalue); + for (i = 0; i < MyManager.varmap.varcnt; i++) + { + free(MyManager.varmap.vars[i]); + free(MyManager.varmap.mvars[i].probabilities); + free(MyManager.varmap.mvars[i].booleanVars); + } + free(MyManager.varmap.vars); + free(MyManager.varmap.mvars); + free(MyManager.varmap.bVar2mVar); + } + if (params.error != NULL) free(params.error); + + return code; + +} + +/* Shell Parameters handling */ + +int argtype(const char *arg) { + if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; + if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; + if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; + if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; + if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; + if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; + if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; + if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; + if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; + if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; + if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; + if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; + return -1; +} + +void printhelp(int argc, char **arg) { + fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); + fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); + fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); + fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); + fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); + fprintf(stderr, "Optional parameters:\n"); + fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); + fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); + fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); + fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); + fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); + fprintf(stderr, "Extra parameters:\n"); + fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); + fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); + fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); + fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); + fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); + fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); +} + +parameters loadparam(int argc, char **arg) { + int i; + parameters params; + params.loadfile = -1; + params.savedfile = -1; + params.exportfile = -1; + params.method = 0; + params.inputfile = -1; + params.debug = 0; + params.errorcnt = 0; + params.queryid = 0; + params.timeout = 0; + params.sigmoid_slope = 1.0; + params.online = 0; + params.maxbufsize = 0; + params.ppid = NULL; + params.error = (int *) malloc(argc * sizeof(int)); + for (i = 1; i < argc; i++) { + switch(argtype(arg[i])) { + case 0: + if (argc > i + 1) { + i++; + params.loadfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 2: + if (argc > i + 1) { + i++; + params.exportfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 3: + if (argc > i + 1) { + i++; + params.method = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 4: + if (argc > i + 1) { + i++; + params.inputfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 5: + printhelp(argc, arg); + break; + case 6: + params.debug = 1; + break; + case 7: + if (argc > i + 1) { + i++; + params.queryid = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 8: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.timeout = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 9: + if (argc > i + 1) { + i++; + params.savedfile = i; + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 10: + if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { + i++; + params.sigmoid_slope = atof(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 11: + params.online = 1; + break; + case 12: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.maxbufsize = atoi(arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + case 13: + if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { + i++; + params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); + strcpy(params.ppid, arg[i]); + } else { + params.error[params.errorcnt] = i; + params.errorcnt++; + } + break; + default: + params.error[params.errorcnt] = i; + params.errorcnt++; + break; + } + } + return params; +} + +/* Error Handlers */ + +void handler(int num) { + fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); + exit(-1); +} + +void pidhandler(int num) { + char *s; + if (params.timeout > 0) { + params.timeout -= 5; + if (params.timeout <= 0) { + fprintf(stderr, "Error: Timeout exceeded.\n"); + exit(-1); + } + } + s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); + strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); + if (system(s) != 0) exit(4); + signal(SIGALRM, pidhandler); + alarm(5); + free(s); +} + +void termhandler(int num) { + exit(3); +} + +/* General Functions */ + +double sigmoid(double x, double slope) { + return 1 / (1 + exp(-x * slope)); +} + +/* Debugging traverse function */ + +void myexpand(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + printf("%s\n", curnode); + if ((Current != MyManager.t) && (Current != MyManager.f) && + ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + printf("l(%s)->", curnode); + myexpand(MyManager, l); + printf("h(%s)->", curnode); + myexpand(MyManager, h); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); + } +} + +/* Angelikas Algorithm */ + +double CalcProbability(extmanager MyManager, DdNode *Current) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + double lvalue, hvalue, tvalue; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) return 1.0; + if (Current == MyManager.f) return 0.0; + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcProbability(MyManager, l); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcProbability(MyManager, h); + tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; + tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); + return tvalue; +} + +/* Bernds Algorithm */ + +gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + gradientpair lvalue, hvalue, tvalue; + double this_probability; + double *gradient; + if (params.debug) { + curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); + fprintf(stderr, "%s\n", curnode); + } + if (Current == MyManager.t) { + tvalue.probability = 1.0; + tvalue.gradient = 0.0; + return tvalue; + } + if (Current == MyManager.f) { + tvalue.probability = 0.0; + tvalue.gradient = 0.0; + return tvalue; + } + if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { + tvalue.probability = Found->dvalue; + tvalue.gradient = *((double *) Found->dynvalue); + return tvalue; + } + l = LowNodeOf(MyManager.manager, Current); + h = HighNodeOf(MyManager.manager, Current); + if (params.debug) fprintf(stderr, "l(%s)->", curnode); + lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); + if (params.debug) fprintf(stderr, "h(%s)->", curnode); + hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); + this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); + tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; + tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; + if ((GetIndex(Current) == TargetVar) || + ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { + tvalue.gradient += hvalue.probability - lvalue.probability; + } + gradient = (double *) malloc(sizeof(double)); + *gradient = tvalue.gradient; + AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); + return tvalue; +} + +char * extractpattern(char *thestr) { + char *p; + int i = 0, sl = strlen(thestr); + while((thestr[i] != '_') && (i < sl)) i++; + if (i == sl) return NULL; + i++; + p = (char *) malloc(sizeof(char) * (i + 2)); + strncpy(p, thestr, i); + p[i] = '*'; + p[i + 1] = '\0'; + return p; +} + +int patterncalculated(char *pattern, extmanager MyManager, int loc) { + int i; + if (pattern == NULL) return 0; + for (i = loc - 1; i > -1; i--) + if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; + return 0; +} + +double Prob(extmanager MyManager, DdNode *node, int comp) +/* compute the probability of the expression rooted at node +nodes is used to store nodes for which the probability has alread been computed +so that it is not recomputed + */ +{ + int index,mVarIndex,nBit; + variable v; + hisnode *Found; + double res; + double value; + + + //index=node->index; + //printf("Prob node %d\n",node); + //index=Cudd_NodeReadIndex(node); + //printf("Prob INdex %d\n",index); + if (Cudd_IsConstant(node)) + { + value=Cudd_V(node);//node->type.value; + //printf("Value %e comp %d\n",value,comp); + if (comp)//Cudd_IsComplement(node)) + //return (1.0-value); + //if (value>0) + { +// printf("return 0"); + return 0.0; + } + else + { +// printf("return 1"); + return 1.0; + } +/*else + if (value>0) + return 1.0; + else + return 0.0; +*/ //return value; + } + else +{ + Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); + + if (Found!=NULL) + { + //printf("value found %e\n",*value_p); + return Found->dvalue; + } + else + { + index=Cudd_NodeReadIndex(node); + //printf("node absent %d comp %d\n",node,comp); + //mVarIndex=array_fetch(int,bVar2mVar,index); + mVarIndex=MyManager.varmap.bVar2mVar[index]; + //v=array_fetch(variable,vars,mVarIndex); + v=MyManager.varmap.mvars[mVarIndex]; + nBit=v.nBit; +// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); + //scanf("%d",&r); + res=ProbBool(MyManager,node,0,nBit,0,v,comp); + //printf("New val %e\n",res); + AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); + return res; + } +} +} + +double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) +/* explores a group of binary variables making up the multivalued variable v */ +{ + DdNode *T,*F; + double p,res; + double * probs; + int index; +// printf("ProbBool nBit %d\n",nBit); + //scanf("%d",&r); + probs=v.probabilities; + if (nBit==0) + { + //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); +// printf("bits %d v.nbit %d\n",bits,v.nBit); + if (bits>=v.nVal) + //if (comp) + { + //printf("bits>=v.nbit return 0\n"); + return 0.0; + } + //else + //{printf("return 0\n"); + //return 1.0;}} + else + { + // printf("Val %d\n",bits); + + //p=array_fetch(double,probs,bits); + p=probs[bits]; + //printf("prob %e\n",p); + res=p*Prob(MyManager,node,comp); + //printf("prob %e\n",p); + //printf("bottom %e\n",res); + return res; + } + } + else + { + //if (correctPosition(node->index,v,node,posBVar)) + index=Cudd_NodeReadIndex(node); + //printf("index %d\n",Cudd_NodeReadIndex(node)); + if (correctPosition(index,v,node,posBVar)) + { + //printf("node %d\n",node); + T = Cudd_T(node);//node->type.kids.T; + F = Cudd_E(node);//node->type.kids.E; + bits=bits<<1; + //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); + res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); + //printf("comp %d ",comp); + comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); + //printf("comp %d \n",comp); +res=res+ + ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); + //printf("res 2 %e\n",res); + return res; + } + else + { + //printf("absent var\n"); + bits=bits<<1; + // printf("Var =1\n"); + res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); + //printf("res 1 %e\n",res); +//printf("var =0\n"); + res=res+ + ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); + // printf("res 2 %e\n",res); +return res; + } + } +} + +int correctPosition(int index,variable v, DdNode * node,int posBVar) +/* returns 1 is the boolean variable with index posBVar is in the correct position +currently explored by ProbBool */ +{ + DdNode * bvar; +//printf("posbvar %d\n",posBVar); +//printf("length %d\n",array_n(v.booleanVars)); + //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); + bvar=v.booleanVars[posBVar]; + + // return var->index==index; +return(Cudd_NodeReadIndex(bvar)==index); +} + +gint my_equal(gconstpointer v,gconstpointer v2) +/* function used by GHashTable to compare two keys */ +{ + DdNode *a,*b; + a=*(DdNode **)v; + b=*(DdNode **)v2; + return (a==b); +} +guint my_hash(gconstpointer key) +/* function used by GHashTable to hash a key */ +{ + unsigned int h; + h=(unsigned int)((unsigned long) *((DdNode **)key) % dividend); + return h; +} +void dealloc(gpointer key,gpointer value,gpointer user_data) +{ + free(key); + free(value); +} +double ret_prob(extmanager MyManager, DdNode * bdd) +{ + int intBits,j; + double prob; + nodes=g_hash_table_new(my_hash,my_equal); + intBits=sizeof(unsigned int)*8; + /* dividend is a global variable used by my_hash + it is equal to an unsigned int with binary representation 11..1 */ + dividend=1; + for(j=1;j= sl) return 0; + if ((thestr[j] == pattern[i]) && patternmatch(pattern + i, thestr + j)) return 1; + } while(1); + } else { + j++; + if (j >= sl) return 0; + if (pattern[i] != thestr[j]) return 0; + } + } + return (pl == sl); +} diff --git a/packages/cplint/approx/simplecuddLPADs/general.h b/packages/cplint/approx/simplecuddLPADs/general.h new file mode 100644 index 000000000..4441ed623 --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/general.h @@ -0,0 +1,159 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: general.h * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include +#include +#include + +#define IsNumberDigit(c) ('0' <= c && c <= '9') +#define IsSignDigit(c) (c == '+' || c == '-') +#define isOperator(x) (x == '+' || x == '*' || x == '#' || x == '=') +#define freadline(fd) freadstr(fd, "\n"); + +int IsRealNumber(char *c); +int IsPosNumber(const char *c); +int IsNumber(const char *c); +char * freadstr(FILE *fd, const char *separators); +int CharIn(const char c, const char *in); +int patternmatch(char *pattern, char *thestr); diff --git a/packages/cplint/approx/simplecuddLPADs/simplecudd.c b/packages/cplint/approx/simplecuddLPADs/simplecudd.c new file mode 100644 index 000000000..e361aeb91 --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/simplecudd.c @@ -0,0 +1,1747 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: simplecudd.c * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include "simplecudd.h" + +/* BDD manager initialization */ + +int _debug = 0; +int _RapidLoad = 0; +int _maxbufsize = 0; +int boolVars=0; + +DdManager* simpleBDDinit(int varcnt) { + DdManager *temp; + temp = Cudd_Init(varcnt, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0); + Cudd_AutodynEnable(temp, CUDD_REORDER_GROUP_SIFT); + Cudd_SetMaxCacheHard(temp, 1024*1024*1024); + Cudd_SetLooseUpTo(temp, 1024*1024*512); + if (_debug) + Cudd_EnableReorderingReporting(temp); + return temp; +} + +/* BDD tree travesrsing */ + +DdNode* HighNodeOf(DdManager *manager, DdNode *node) { + DdNode *tmp; + if (IsHigh(manager, node)) return HIGH(manager); + if (IsLow(manager, node)) return LOW(manager); + tmp = Cudd_Regular(node); + if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.T); + return tmp->type.kids.T; +} + +DdNode* LowNodeOf(DdManager *manager, DdNode *node) { + DdNode *tmp; + if (IsHigh(manager, node)) return HIGH(manager); + if (IsLow(manager, node)) return LOW(manager); + tmp = Cudd_Regular(node); + if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.E); + return tmp->type.kids.E; +} + +/* BDD tree generation */ + +DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddAnd(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddNand(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddOr(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddNor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddXor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { + DdNode *tmp; + tmp = Cudd_bddXnor(manager, bdd1, bdd2); + Cudd_Ref(tmp); + Cudd_RecursiveDeref(manager, bdd2); + return tmp; +} + +/* file manipulation */ + +bddfileheader ReadFileHeader(char *filename) { + bddfileheader temp; + char *header; + temp.inputfile = NULL; + temp.version = 0; + temp.varcnt = 0; + temp.varstart = 0; + temp.intercnt = 0; + temp.filetype = BDDFILE_OTHER; + if ((temp.inputfile = fopen(filename, "r")) == NULL) { + perror(filename); + temp.filetype = BDDFILE_ERROR; + return temp; + } + // Read file header + if (!feof(temp.inputfile)) { + header = freadline(temp.inputfile); + temp.version = CheckFileVersion(header); + if (temp.version > -1) temp.filetype = (strlen(header) == 5) * BDDFILE_SCRIPT + (strlen(header) == 7) * BDDFILE_NODEDUMP; + free(header); + switch (temp.filetype) { + case BDDFILE_SCRIPT: + switch (temp.version) { + case 1: + fscanf(temp.inputfile, "%i\n", &temp.varcnt); + fscanf(temp.inputfile, "%i\n", &temp.bvarcnt); + fscanf(temp.inputfile, "%i\n", &temp.varstart); + fscanf(temp.inputfile, "%i\n", &temp.intercnt); + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + break; + case BDDFILE_NODEDUMP: + switch (temp.version) { + case 1: + fscanf(temp.inputfile, "%i\n", &temp.varcnt); + fscanf(temp.inputfile, "%i\n", &temp.varstart); + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + break; + case BDDFILE_OTHER: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + default: + fclose(temp.inputfile); + temp.inputfile = NULL; + break; + } + } + return temp; +} + +int CheckFileVersion(const char *version) { + if (strlen(version) < 5) return -1; + if (strlen(version) == 5 && version[0] == '@' && version[1] == 'B' && version[2] == 'D' && version[3] == 'D') return atoi(version + 4); + if (strlen(version) == 7 && version[0] == '@' && version[1] == 'N' && version[2] == 'O' && version[3] == 'D' + && version[4] == 'E' && version[5] == 'S') return atoi(version + 6); + return -1; +} + +int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) { + DdNode *f[1]; + int ret; + FILE *fd; + f[0] = Cudd_BddToAdd(manager, bdd); + fd = fopen(filename, "w"); + if (fd == NULL) { + perror(filename); + return -1; + } + ret = Cudd_DumpDot(manager, 1, f, NULL, NULL, fd); + fclose(fd); + return ret; +} + +int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { + DdNode *f[1]; + int ret; + FILE *fd; + f[0] = Cudd_BddToAdd(manager, bdd); + fd = fopen(filename, "w"); + if (fd == NULL) { + perror(filename); + return -1; + } + ret = Cudd_DumpDot(manager, 1, f, varmap.vars, NULL, fd); + fclose(fd); + return ret; +} + +int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { + hisqueue *Nodes; + FILE *outputfile; + int i; + if ((outputfile = fopen(filename, "w")) == NULL) { + perror(filename); + return -1; + } + fprintf(outputfile, "%s\n%i\n%i\n", "@NODES1", varmap.varcnt, varmap.varstart); + Nodes = InitHistory(varmap.varcnt); + for (i = 0; i < varmap.varcnt; i++) + fprintf(outputfile, "%s\t%i\n", varmap.vars[i], Cudd_ReadPerm(manager, i)); + if (bdd == HIGH(manager)) fprintf(outputfile, "TRUE\t0\tTRUE\t0\tTRUE\t0\n"); + else if (bdd == LOW(manager)) fprintf(outputfile, "FALSE\t0\tFALSE\t0\tFALSE\t0\n"); + else SaveExpand(manager, varmap, Nodes, bdd, outputfile); + ReInitHistory(Nodes, varmap.varcnt); + free(Nodes); + fclose(outputfile); + return 0; +} + +void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile) { + DdNode *h, *l; + hisnode *Found; + char *curnode; + int inode; + if (Current != HIGH(manager) && Current != LOW(manager)) { + if ((Found = GetNode(Nodes, varmap.varstart, Current)) == NULL) { + AddNode(Nodes, varmap.varstart, Current, 0.0, 0, NULL); + Found = GetNode(Nodes, varmap.varstart, Current); + } + if (!(Found->ivalue)) { + Found->ivalue = 1; + curnode = GetNodeVarNameDisp(manager, varmap, Current); + inode = GetNodeIndex(Nodes, varmap.varstart, Current); + fprintf(outputfile, "%s\t%i\t", curnode, inode); + h = HighNodeOf(manager, Current); + if (h == HIGH(manager)) { + fprintf(outputfile, "TRUE\t0\t"); + } else if (h == LOW(manager)) { + fprintf(outputfile, "FALSE\t0\t"); + } else { + if (GetNode(Nodes, varmap.varstart, h) == NULL) AddNode(Nodes, varmap.varstart, h, 0.0, 0, NULL); + curnode = GetNodeVarNameDisp(manager, varmap, h); + inode = GetNodeIndex(Nodes, varmap.varstart, h); + fprintf(outputfile, "%s\t%i\t", curnode, inode); + } + l = LowNodeOf(manager, Current); + if (l == HIGH(manager)) { + fprintf(outputfile, "TRUE\t0\n"); + } else if (l == LOW(manager)) { + fprintf(outputfile, "FALSE\t0\n"); + } else { + if (GetNode(Nodes, varmap.varstart, l) == NULL) AddNode(Nodes, varmap.varstart, l, 0.0, 0, NULL); + curnode = GetNodeVarNameDisp(manager, varmap, l); + inode = GetNodeIndex(Nodes, varmap.varstart, l); + fprintf(outputfile, "%s\t%i\n", curnode, inode); + } + SaveExpand(manager, varmap, Nodes, l, outputfile); + SaveExpand(manager, varmap, Nodes, h, outputfile); + } + } +} + +DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile) { + hisqueue *Nodes; + nodeline temp; + DdNode *ret; + int i, pos, *perm; + char *varnam; + perm = (int *) malloc(sizeof(int) * varmap.varcnt); + Nodes = InitHistory(varmap.varcnt); + for (i = 0; i < varmap.varcnt; i++) { + varnam = freadstr(inputfile, "\t"); + pos = atoi(freadstr(inputfile, "\n")); + AddNamedVarAt(varmap, varnam, pos); + perm[pos] = pos; + } + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + ret = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + fclose(inputfile); + ReInitHistory(Nodes, varmap.varcnt); + free(Nodes); + Cudd_Ref(ret); + Cudd_ShuffleHeap(manager, perm); + for (i = 0; i < varmap.varcnt; i++) varmap.ivalue[i] = 0; + return ret; +} + +DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current) { + nodeline temp; + DdNode *newnode, *truenode, *falsenode; + int index; + newnode = GetIfExists(manager, varmap, Nodes, current.varname, current.nodenum); + if (newnode != NULL) return newnode; + falsenode = GetIfExists(manager, varmap, Nodes, current.falsevar, current.falsenode); + if (falsenode == NULL) { + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + falsenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + } + truenode = GetIfExists(manager, varmap, Nodes, current.truevar, current.truenode); + if (truenode == NULL) { + temp.varname = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.nodenum); + temp.truevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\t", &temp.truenode); + temp.falsevar = freadstr(inputfile, "\t"); + fscanf(inputfile, "%i\n", &temp.falsenode); + truenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); + free(temp.varname); + free(temp.truevar); + free(temp.falsevar); + } + index = GetNamedVarIndex(varmap, current.varname); + if (!varmap.ivalue[index]) { + varmap.ivalue[index] = 1; + newnode = GetVar(manager, varmap.varstart + index); + //Cudd_RecursiveDeref(manager, newnode->type.kids.T); + //Cudd_RecursiveDeref(manager, newnode->type.kids.E); + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } else { + if (_RapidLoad == 1) { + newnode = cuddAllocNode(manager); + if (newnode != NULL) { + newnode->index = varmap.varstart + index; + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } + } else { + newnode = cuddUniqueInter(manager, varmap.varstart + index, Cudd_NotCond(truenode, Cudd_IsComplement(truenode)), Cudd_NotCond(falsenode, Cudd_IsComplement(truenode))); + if (newnode != NULL) { + Cudd_Ref(newnode); + } else { + newnode = cuddAllocNode(manager); + if (newnode != NULL) { + newnode->index = varmap.varstart + index; + newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); + newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); + Cudd_Ref(newnode->type.kids.T); + Cudd_Ref(newnode->type.kids.E); + Cudd_Ref(newnode); + } + } + } + } + if (newnode != NULL) { + Nodes[index].thenode[current.nodenum].key = Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); + return Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); + } + return NULL; +} + +DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum) { + int index; + if (strcmp(varname, "TRUE") == 0) return HIGH(manager); + if (strcmp(varname, "FALSE") == 0) return LOW(manager); + index = GetNamedVarIndex(varmap, varname); + if (index == -1 * varmap.varcnt) { + fprintf(stderr, "Error: more variables requested than initialized.\n"); + exit(-1); + } + if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { + index = AddNamedVar(varmap, varname); + } + ExpandNodes(Nodes, index, nodenum); + if (Nodes[index].thenode[nodenum].key != NULL) return Nodes[index].thenode[nodenum].key; + return NULL; +} + +void ExpandNodes(hisqueue *Nodes, int index, int nodenum) { + int i; + if (Nodes[index].cnt > nodenum) return; + Nodes[index].thenode = (hisnode *) realloc(Nodes[index].thenode, (nodenum + 1) * sizeof(hisnode)); + for (i = Nodes[index].cnt; i < nodenum + 1; i++) { + Nodes[index].thenode[i].key = NULL; + Nodes[index].thenode[i].ivalue = 0; + Nodes[index].thenode[i].dvalue = 0.0; + Nodes[index].thenode[i].dynvalue = NULL; + } + Nodes[index].cnt = nodenum + 1; +}; + +int LoadVariableData(namedvars varmap, char *filename) { + FILE *data; + char *dataread, buf, *varname, *dynvalue; + double dvalue = 0.0; + int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; + dynvalue = NULL; + if ((data = fopen(filename, "r")) == NULL) { + perror("fopen"); + return -1; + } + printf("filename %s\n",filename); + dataread = (char *) malloc(sizeof(char) * maxbufsize); + while(!feof(data)) { + index++; + printf("index %d\n",index); + fscanf(data,"@%s\n",dataread); + + varname = (char *) malloc(sizeof(char) * strlen(dataread)); + strcpy(varname, dataread); + varmap.vars[index]=varname; + fscanf(data, "%di\n", &values); + varmap.mvars[index].nVal=values; + varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); + varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); + varmap.mvars[index].booleanVars=(int *)malloc(sizeof(int)*varmap.mvars[index].nBit); + + free(varname); + } + fclose(data); + free(dataread); + return 0; +} + +int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename) { + FILE *data; + char *dataread, buf, *varname, *dynvalue; + double dvalue = 0.0; + int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; + dynvalue = NULL; + if ((data = fopen(filename, "r")) == NULL) { + perror("fopen"); + return -1; + } + dataread = (char *) malloc(sizeof(char) * maxbufsize); + while(!feof(data)) { + index++; + if(fscanf(data,"@%s\n",dataread)<1) break; + varname = (char *) malloc(sizeof(char) * strlen(dataread)); + strcpy(varname, dataread); + varmap.vars[index]=varname; + //printf("vname %d %s\n",index, varmap.vars[index]); + + fscanf(data, "%d\n", &values); + varmap.loaded[index] = 1; + varmap.mvars[index].init=0; + varmap.mvars[index].nVal=values; + varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); + varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); + varmap.mvars[index].booleanVars=(DdNode **)malloc(sizeof(DdNode *)*varmap.mvars[index].nBit); + for (i=0;ivars = (char **) realloc(varmap->vars, sizeof(char *) * newvarcnt); + varmap->loaded = (int *) realloc(varmap->loaded, sizeof(int) * newvarcnt); + varmap->dvalue = (double *) realloc(varmap->dvalue, sizeof(double) * newvarcnt); + varmap->ivalue = (int *) realloc(varmap->ivalue, sizeof(int) * newvarcnt); + varmap->dynvalue = (void **) realloc(varmap->dynvalue, sizeof(int) * newvarcnt); + for (i = varmap->varcnt; i < newvarcnt; i++) { + varmap->vars[i] = NULL; + varmap->loaded[i] = 0; + varmap->dvalue[i] = 0.0; + varmap->ivalue[i] = 0; + varmap->dynvalue[i] = NULL; + } + varmap->varcnt = newvarcnt; +} + +int AddNamedVarAt(namedvars varmap, const char *varname, int index) { + if (varmap.varcnt > index) { + varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); + strcpy(varmap.vars[index], varname); + return index; + } + return -1; +} + +int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int *value) { + + int index,i,l,nBit; + int *booleanVars; + char * vname; + l=strlen(varname); + //printf("addnamed %s\n",varname); + i=0; + while (varname[i]!='-') + { + i++; + } + vname=(char *)malloc(sizeof(char)*(l+1)); + strncpy(vname,varname,i); + vname[i]='\0'; + //printf("addnamed vname %s\n",vname); + sscanf(varname+i+1,"%d",value); + index= GetNamedVarIndex(varmap, vname); + //printf("index %d\n",index); + //printf("init %d\n",varmap.mvars[index].init); + if (index == -1 * varmap.varcnt) { + return -1; + } else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { + index *= -1; + varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); + } + if (varmap.mvars[index].init==0){ + nBit=varmap.mvars[index].nBit; + booleanVars= varmap.mvars[index].booleanVars; + //Cudd_MakeTreeNode(mgr,boolVars,nBit,MTR_FIXED); + for (i=0;ivars[varmap->varcnt - 1] == NULL) + varmap->varcnt--; + return varmap->varcnt; +} + +int all_loaded(namedvars varmap, int disp) { + int i, res = 1; + for (i = 0; i < varmap.varcnt; i++) { + if (varmap.loaded[i] == 0) { + res = 0; + if (disp) fprintf(stderr, "The variable: %s was not loaded with values.\n", varmap.vars[i]); else return 0; + } + } + return res; +} + +/* Parser */ + +DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader) { + int icomment, maxlinesize, icur, iline, curinter, iequal ; + DdNode *Line, **inter; + char buf, *inputline, *filename; + bddfileheader interfileheader; + long startAt, endAt; + double secs; + + // Initialization of intermediate steps + inter = (DdNode **) malloc(sizeof(DdNode *) * fileheader.intercnt); + for (icur = 0; icur < fileheader.intercnt; icur++) inter[icur] = NULL; + // Read file data + interfileheader.inputfile = NULL; + filename = NULL; // For nested files + iequal = 0; // Flag for encountered = sign + icur = 0; // Pointer for inputline buffer location + iline = 5; // Current file line (first after header) + icomment = 0; // Flag for comments + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + while(!feof(fileheader.inputfile)) { + fread(&buf, 1, 1, fileheader.inputfile); + if (buf == ';' || buf == '%' || buf == '$') icomment = 1; + if (buf == '\n') { + if (icomment) icomment = 0; + /* if (iequal > 1) { + fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } else*/ + iequal = 0; + if (icur > 0) { + inputline[icur] = '\0'; + if (inputline[0] != 'L') { + fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + curinter = getInterBDD(inputline); + if (curinter == -1) { + if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { + curinter = atoi(inputline + 1) - 1; + if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { + if (_debug) fprintf(stderr, "Returned: %s\n", inputline); + fclose(fileheader.inputfile); + Line = inter[curinter]; + free(inter); + free(inputline); + return Line; + } else { + fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] == NULL) { + if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); + filename = getFileName(inputline); + if (filename == NULL) { + startAt = clock(); + Line = LineParser(manager, varmap, inter, fileheader.intercnt, inputline, iline); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC)*1000; + //printf("line %e\n",secs); + } else { + interfileheader = ReadFileHeader(filename); + if (interfileheader.inputfile == NULL) { + //Line = simpleBDDload(manager, &varmap, filename); + Line = NULL; + } else { + Line = FileGenerateBDD(manager, varmap, interfileheader); + } + if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); + free(filename); + filename = NULL; + interfileheader.inputfile = NULL; + } + if (Line == NULL) { + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + inter[curinter] = Line; + icur = 0; + } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { + fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } else { + fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + } + iline++; + } else if (buf != ' ' && buf != '\t' && !icomment) { + if (buf == '=') iequal++; + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } + fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); + fclose(fileheader.inputfile); + free(inter); + free(inputline); + return NULL; +} + + +int getInterBDD(char *function) { + int i, ret; + char *inter; + for (i = 0; i < strlen(function); i++) { + if (function[i] == '=') { + inter = (char *) malloc(sizeof(char) * i); + strncpy(inter, function + 1, i - 1); + inter[i - 1] = '\0'; + if (IsPosNumber(inter)) { + ret = atoi(inter) - 1; + free(inter); + return ret; + } else { + free(inter); + return -1; + } + } + } + return -1; +} + +char* getFileName(const char *function) { + int i = 0; + char *filename; + while(function[i] != '=' && (i + 1) < strlen(function)) i++; + if ((i + 1) < strlen(function)) { + i++; + if (function[i] == '<' && function[strlen(function) - 1] == '>') { + filename = (char *) malloc(sizeof(char) * strlen(function) - i); + strcpy(filename, function + i + 1); + filename[strlen(function) - i - 2] = '\0'; + return filename; + } + } + return NULL; +} + +DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline) { + int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst,value; + long startAt, endAt; + double secs; + DdNode *bdd; + char *term, curoper; + bdd = HIGH(manager); + Cudd_Ref(bdd); + term = NULL; + ivar = -1; + curoper = '*'; + istart = -1; + iend = strlen(function) - 1; + ilength = -1; + symbol = -1; + inegvar = 0; + inegoper = 0; + iconst = 0; + for (i = strlen(function) - 1; i > -1; i--) { + if (symbol == -1 && isOperator(function[i])) { + symbol = i; + istart = i + 1; + ilength = iend - i; + iend = i - 1; + if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { + term = (char *) malloc(sizeof(char) * (ilength + 1)); + strncpy(term, function + istart, ilength); + term[ilength] = '\0'; + } else { + fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); + free(term); + return NULL; + } + } + if (symbol != -1) { + if (term[0] == '~') inegvar = 1; else inegvar = 0; + if (term[0 + inegvar] != 'L') { + // Term is a variable + if (strcmp(term + inegvar, "TRUE") == 0) { + iconst = 1; + } else if (strcmp(term + inegvar, "FALSE") == 0) { + iconst = 1; + inegvar = 1; + } else { + iconst = 0; + //printf("term %s\n",term + inegvar); + ivar = AddNamedMultiVar(manager,varmap, term + inegvar,&value); + //printf("term %s var %d\n",term + inegvar,ivar); + + if (ivar == -1) { + fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); + free(term); + return NULL; + } + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap.varstart)), + Cudd_CountPath(GetVar(manager, ivar + varmap.varstart)), + Cudd_DagSize(GetVar(manager, ivar + varmap.varstart)) ); + startAt = clock(); + if (!iconst) { + if (inegvar) bdd = BDD_Operator(manager, NOT(GetMVar(manager, ivar + varmap.varstart,value,varmap)), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, GetMVar(manager, ivar + varmap.varstart,value,varmap), bdd, curoper, inegoper); + } else { + switch(curoper) { + case '+': + if (inegvar ^ inegoper) ; else { + bdd = HIGH(manager); + Cudd_Ref(bdd); + } + break; + case '*': + if (inegvar ^ inegoper) { + bdd = LOW(manager); + Cudd_Ref(bdd); + } + break; + case '#': + if (inegvar ^ inegoper) ; else bdd = NOT(bdd); + break; + } + } + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } else { + // Term is an intermediate result + if (IsPosNumber(term + inegvar + 1)) + { + ivar = atoi(term + inegvar + 1) - 1; + } + else { + fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); + free(term); + return NULL; + } + if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); + free(term); + return NULL; + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(inter[ivar]), + Cudd_CountPath(inter[ivar]), + Cudd_DagSize(inter[ivar]) ); + startAt = clock(); + if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } + free(term); + term = NULL; + curoper = function[symbol]; + if (curoper == '=') return bdd; + if (function[symbol - 1] == '~') { + inegoper = 1; + i--; + iend--; + } else { + inegoper = 0; + } + symbol = -1; + } + } + return NULL; +} + +DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper) { + switch (Operator) { + case '+': + if (inegoper) return D_BDDNor(manager, bdd1, bdd2); + else return D_BDDOr(manager, bdd1, bdd2); + break; + case '*': + if (inegoper) return D_BDDNand(manager, bdd1, bdd2); + else return D_BDDAnd(manager, bdd1, bdd2); + break; + case '#': + if (inegoper) return D_BDDXnor(manager, bdd1, bdd2); + else return D_BDDXor(manager, bdd1, bdd2); + break; + default: + return NULL; + break; + } +} + +DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap) { + int icomment, maxlinesize, icur, iline, curinter, iequal, iinters, itmp, i; + DdNode *Line, **inter; + char buf, *inputline, *filename; + bddfileheader interfileheader; + // Initialization of intermediate steps + iinters = 1; + inter = (DdNode **) malloc(sizeof(DdNode *) * iinters); + for (icur = 0; icur < iinters; icur++) inter[icur] = NULL; + // Read file data + interfileheader.inputfile = NULL; + filename = NULL; // For nested files + iequal = 0; // Flag for encountered = sign + icur = 0; // Pointer for inputline buffer location + iline = 1; // Current file line (first after header) + icomment = 0; // Flag for comments + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + + do { + buf = fgetc(stdin); + if (buf == ';' || buf == '%' || buf == '$') icomment = 1; + if (buf == '\n') { + if (icomment) icomment = 0; + if (iequal > 1) { + fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); + free(inter); + free(inputline); + return NULL; + } else iequal = 0; + if (icur > 0) { + inputline[icur] = '\0'; + if (inputline[0] == '@') { + if (inputline[1] == 'e') { + free(inter); + free(inputline); + exit(0); + } else { + itmp = GetParam(inputline, 1); + if (itmp > varmap->varcnt) + EnlargeNamedVars(varmap, itmp); + itmp = GetParam(inputline, 2); + if (itmp > iinters) { + inter = (DdNode **) realloc(inter, sizeof(DdNode *) * itmp); + for (i = iinters; i < itmp; i++) inter[i] = NULL; + iinters = itmp; + } + } + icur = 0; + } else { + if (inputline[0] != 'L') { + fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); + free(inter); + free(inputline); + return NULL; + } + curinter = getInterBDD(inputline); + if (curinter == -1) { + if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { + curinter = atoi(inputline + 1) - 1; + if (curinter > -1 && curinter < iinters && inter[curinter] != NULL) { + if (_debug) fprintf(stderr, "Returned: %s\n", inputline); + Line = inter[curinter]; + free(inter); + free(inputline); + return Line; + } else { + fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else if (curinter > -1) { + if (curinter >= iinters) { + inter = (DdNode **) realloc(inter, sizeof(DdNode *) * (curinter + 1)); + for (i = iinters; i < curinter + 1; i++) inter[i] = NULL; + iinters = curinter + 1; + } + if (inter[curinter] == NULL) { + if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); + filename = getFileName(inputline); + if (filename == NULL) { + Line = OnlineLineParser(manager, varmap, inter, iinters, inputline, iline); + } else { + interfileheader = ReadFileHeader(filename); + if (interfileheader.inputfile == NULL) { + //Line = simpleBDDload(manager, varmap, filename); + Line = NULL; + } else { + Line = FileGenerateBDD(manager, *varmap, interfileheader); + } + if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); + free(filename); + filename = NULL; + interfileheader.inputfile = NULL; + } + if (Line == NULL) { + free(inter); + free(inputline); + return NULL; + } + inter[curinter] = Line; + icur = 0; + } else if (inter[curinter] != NULL) { + fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } else { + fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); + free(inter); + free(inputline); + return NULL; + } + } + } + iline++; + } else if (buf != ' ' && buf != '\t' && !icomment) { + if (buf == '=') iequal++; + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + free(inter); + free(inputline); + return NULL; + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } while(1); + fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); + free(inter); + free(inputline); + return NULL; +} + +DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline) { + int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst; + long startAt, endAt; + double secs; + DdNode *bdd; + char *term, curoper; + bdd = HIGH(manager); + Cudd_Ref(bdd); + term = NULL; + ivar = -1; + curoper = '*'; + istart = -1; + iend = strlen(function) - 1; + ilength = -1; + symbol = -1; + inegvar = 0; + inegoper = 0; + iconst = 0; + for (i = strlen(function) - 1; i > -1; i--) { + if (symbol == -1 && isOperator(function[i])) { + symbol = i; + istart = i + 1; + ilength = iend - i; + iend = i - 1; + if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { + term = (char *) malloc(sizeof(char) * (ilength + 1)); + strncpy(term, function + istart, ilength); + term[ilength] = '\0'; + } else { + fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); + free(term); + return NULL; + } + } + if (symbol != -1) { + if (term[0] == '~') inegvar = 1; else inegvar = 0; + if (term[0 + inegvar] != 'L') { + // Term is a variable + if (strcmp(term , "TRUE") == 0) { + iconst = 1; + } else if (strcmp(term , "FALSE") == 0) { + iconst = 1; + inegvar = 1; + } else { + iconst = 0; + ivar = AddNamedVar(*varmap, term + inegvar); + if (ivar == -1) { + EnlargeNamedVars(varmap, varmap->varcnt + 1); + ivar = AddNamedVar(*varmap, term + inegvar); + } + if (ivar == -1) { + fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); + free(term); + return NULL; + } + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap->varstart)), + Cudd_CountPath(GetVar(manager, ivar + varmap->varstart)), + Cudd_DagSize(GetVar(manager, ivar + varmap->varstart)) ); + startAt = clock(); + if (!iconst) { + if (inegvar) bdd = BDD_Operator(manager, NOT(GetVar(manager, ivar + varmap->varstart)), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, GetVar(manager, ivar + varmap->varstart), bdd, curoper, inegoper); + } else { + switch(curoper) { + case '+': + if (inegvar ^ inegoper) ; else { + bdd = HIGH(manager); + Cudd_Ref(bdd); + } + break; + case '*': + if (inegvar ^ inegoper) { + bdd = LOW(manager); + Cudd_Ref(bdd); + } + break; + case '#': + if (inegvar ^ inegoper) ; else bdd = NOT(bdd); + break; + } + } + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } else { + // Term is an intermediate result + if (IsPosNumber(term + inegvar + 1)) ivar = atoi(term + inegvar + 1) - 1; else { + fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); + free(term); + return NULL; + } + if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); + free(term); + return NULL; + } + if (_debug) fprintf(stderr, "%s\n", term); + if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", + Cudd_CountPathsToNonZero(bdd), + Cudd_CountPath(bdd), + Cudd_DagSize(bdd), + Cudd_CountPathsToNonZero(inter[ivar]), + Cudd_CountPath(inter[ivar]), + Cudd_DagSize(inter[ivar]) ); + startAt = clock(); + if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); + else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); + endAt = clock(); + secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); + if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); + //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); + if (bdd == NULL) { + fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); + free(term); + return NULL; + } + } + free(term); + term = NULL; + curoper = function[symbol]; + if (curoper == '=') return bdd; + if (function[symbol - 1] == '~') { + inegoper = 1; + i--; + iend--; + } else { + inegoper = 0; + } + symbol = -1; + } + } + return NULL; +} + +int GetParam(char *inputline, int iParam) { + int icoma, istart, iend, ret; + char *numb; + istart = 1; + icoma = istart; + iend = strlen(inputline); + while((inputline[icoma] != ',') && (icoma < iend)) + icoma++; + if (iParam == 1) { + numb = (char *) malloc(sizeof(char) * icoma); + strncpy(numb, inputline + 1, icoma - 1); + numb[icoma - 1] = '\0'; + if (IsPosNumber(numb)) { + ret = atoi(numb); + free(numb); + return ret; + } + } else if(iParam == 2) { + numb = (char *) malloc(sizeof(char) * (iend - icoma + 1)); + strncpy(numb, inputline + icoma + 1, iend - icoma); + numb[iend - icoma] = '\0'; + if (IsPosNumber(numb)) { + ret = atoi(numb); + free(numb); + return ret; + } + } + return 0; +} + +void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd) { + char buf, *inputline; + int icur, maxlinesize, iline, index, iloop, ivalue, iQsize, i, inQ; + double dvalue; + DdNode **Q, **Q2, *h_node, *l_node, *curnode; + hisqueue *his; + hisnode *hnode; + iloop = 1; + icur = 0; // Pointer for inputline buffer location + iline = 1; // Current file line (first after header) + maxlinesize = 80; // inputline starting buffer size + inputline = (char *) malloc(sizeof(char) * maxlinesize); + curnode = bdd; + iQsize = 0; + Q = (DdNode **) malloc(sizeof(DdNode *) * iQsize); + Q2 = NULL; + his = InitHistory(varmap.varcnt); + do { + buf = fgetc(stdin); + if (buf == '\n') { + inputline[icur] = '\0'; + if ((icur > 0) && (inputline[0] == '@') && (inputline[2] == ',' || inputline[2] == '\0')) { + switch(inputline[1]) { + case 'c': + printf("bdd_temp_value('%s', %i).\n", GetNodeVarNameDisp(manager, varmap, curnode), iQsize); + break; + case 'n': + if (curnode != HIGH(manager) && curnode != LOW(manager) && (hnode = GetNode(his, varmap.varstart, curnode)) == NULL) { + AddNode(his, varmap.varstart, curnode, 0.0, 0, NULL); + l_node = LowNodeOf(manager, curnode); + h_node = HighNodeOf(manager, curnode); + inQ = 0; + for(i = 0; (i < iQsize / 2) && (inQ < 3); i++) + inQ = (Q[i] == l_node) || (Q[iQsize - i] == l_node) + 2 * (Q[i] == h_node) || (Q[iQsize - i] == h_node); + if (inQ & 1 == 0) inQ = inQ + (GetNode(his, varmap.varstart, l_node) != NULL); + if (inQ & 2 == 0) inQ = inQ + 2 * (GetNode(his, varmap.varstart, h_node) != NULL); + if (inQ & 1 == 1) inQ = inQ - (l_node == HIGH(manager) || l_node == LOW(manager)); + if (inQ & 2 == 2) inQ = inQ - 2 * (h_node == HIGH(manager) || h_node == LOW(manager)); + switch(inQ) { + case 0: + iQsize += 2; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 2] = l_node; + Q[iQsize - 1] = h_node; + break; + case 1: + iQsize++; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 1] = h_node; + break; + case 2: + iQsize++; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + Q[iQsize - 1] = l_node; + break; + case 3: + break; + default: + break; + } + } + if (inputline[2] == '\0' || strcmp(inputline + 3, "DFS") == 0) { + if (iQsize > 0) { + iQsize--; + curnode = Q[iQsize]; + Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); + } + } else if (strcmp(inputline + 3, "BFS") == 0) { + if (iQsize > 0) { + iQsize--; + curnode = Q[0]; + Q2 = (DdNode **) malloc(sizeof(DdNode *) * iQsize); + for(i = 0; i < iQsize; i++) + Q2[i] = Q[i + 1]; + free(Q); + Q = Q2; + } + } else { + fprintf(stderr, "Error: Could not find method: %s, Correct syntax @n,[DFS, BFS].\n", inputline + 3); + free(Q); + free(inputline); + exit(-1); + } + break; + case 'h': + printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, HighNodeOf(manager, curnode))); + break; + case 'l': + printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, LowNodeOf(manager, curnode))); + break; + case 'v': + index = GetNamedVarIndex(varmap, inputline + 3); + if (index >= 0) { + fprintf(stdout, "bdd_temp_value([%f,%i,%s]).\n", varmap.dvalue[index], varmap.ivalue[index], (char *) varmap.dynvalue[index]); + } else { + fprintf(stderr, "Error: Could not find variable: %s, Correct syntax @v,[variable name].\n", inputline + 3); + free(Q); + free(inputline); + exit(-1); + } + break; + case 'e': + iloop = 0; + break; + default: + fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); + free(Q); + free(inputline); + exit(-1); + break; + } + icur = 0; + } else { + fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); + free(Q); + free(inputline); + exit(-1); + } + iline++; + } else if (buf != ' ' && buf != '\t') { + inputline[icur] = buf; + icur += 1; + if (icur == _maxbufsize) { + fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); + free(Q); + free(inputline); + exit(-1); + } + while (icur > maxlinesize - 1) { + maxlinesize *= 2; + inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); + } + } + } while(iloop); + free(Q); + free(inputline); +} + +DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap) +{ + + int i; + int bit,*booleanVars,booleanVar; + variable v; + DdNode * node, * tmp; + + + v=varmap.mvars[varIndex]; + booleanVars=v.booleanVars; + i=v.nBit-1; + booleanVar=booleanVars[i]; + bit=value & 01; + if (bit) + { + node=Cudd_bddIthVar(mgr, booleanVar); + } + else + { + node=Cudd_Not(Cudd_bddIthVar(mgr, booleanVar)); + } + value=value>>1; + i--; + + while (i>=0) { + booleanVar=booleanVars[i]; + bit=value & 01; + if (bit) + { + tmp=Cudd_bddAnd(mgr,node,Cudd_bddIthVar(mgr, booleanVar)); + Cudd_Ref(tmp); + } + else + { + tmp=Cudd_bddAnd(mgr,node,Cudd_Not(Cudd_bddIthVar(mgr, booleanVar))); + Cudd_Ref(tmp); + } + value=value>>1; + i--; + Cudd_RecursiveDeref(mgr,node); + node=tmp; + } +return node; +} + + + diff --git a/packages/cplint/approx/simplecuddLPADs/simplecudd.h b/packages/cplint/approx/simplecuddLPADs/simplecudd.h new file mode 100644 index 000000000..998ad182b --- /dev/null +++ b/packages/cplint/approx/simplecuddLPADs/simplecudd.h @@ -0,0 +1,306 @@ +/******************************************************************************\ +* * +* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * +* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * +* * +* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * +* * +* Author: Theofrastos Mantadelis * +* File: simplecudd.h * +* * +******************************************************************************** +* * +* The "Artistic License" * +* * +* Preamble * +* * +* The intent of this document is to state the conditions under which a * +* Package may be copied, such that the Copyright Holder maintains some * +* semblance of artistic control over the development of the package, * +* while giving the users of the package the right to use and distribute * +* the Package in a more-or-less customary fashion, plus the right to make * +* reasonable modifications. * +* * +* Definitions: * +* * +* "Package" refers to the collection of files distributed by the * +* Copyright Holder, and derivatives of that collection of files * +* created through textual modification. * +* * +* "Standard Version" refers to such a Package if it has not been * +* modified, or has been modified in accordance with the wishes * +* of the Copyright Holder as specified below. * +* * +* "Copyright Holder" is whoever is named in the copyright or * +* copyrights for the package. * +* * +* "You" is you, if you're thinking about copying or distributing * +* this Package. * +* * +* "Reasonable copying fee" is whatever you can justify on the * +* basis of media cost, duplication charges, time of people involved, * +* and so on. (You will not be required to justify it to the * +* Copyright Holder, but only to the computing community at large * +* as a market that must bear the fee.) * +* * +* "Freely Available" means that no fee is charged for the item * +* itself, though there may be fees involved in handling the item. * +* It also means that recipients of the item may redistribute it * +* under the same conditions they received it. * +* * +* 1. You may make and give away verbatim copies of the source form of the * +* Standard Version of this Package without restriction, provided that you * +* duplicate all of the original copyright notices and associated disclaimers. * +* * +* 2. You may apply bug fixes, portability fixes and other modifications * +* derived from the Public Domain or from the Copyright Holder. A Package * +* modified in such a way shall still be considered the Standard Version. * +* * +* 3. You may otherwise modify your copy of this Package in any way, provided * +* that you insert a prominent notice in each changed file stating how and * +* when you changed that file, and provided that you do at least ONE of the * +* following: * +* * +* a) place your modifications in the Public Domain or otherwise make them * +* Freely Available, such as by posting said modifications to Usenet or * +* an equivalent medium, or placing the modifications on a major archive * +* site such as uunet.uu.net, or by allowing the Copyright Holder to include * +* your modifications in the Standard Version of the Package. * +* * +* b) use the modified Package only within your corporation or organization. * +* * +* c) rename any non-standard executables so the names do not conflict * +* with standard executables, which must also be provided, and provide * +* a separate manual page for each non-standard executable that clearly * +* documents how it differs from the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 4. You may distribute the programs of this Package in object code or * +* executable form, provided that you do at least ONE of the following: * +* * +* a) distribute a Standard Version of the executables and library files, * +* together with instructions (in the manual page or equivalent) on where * +* to get the Standard Version. * +* * +* b) accompany the distribution with the machine-readable source of * +* the Package with your modifications. * +* * +* c) give non-standard executables non-standard names, and clearly * +* document the differences in manual pages (or equivalent), together * +* with instructions on where to get the Standard Version. * +* * +* d) make other distribution arrangements with the Copyright Holder. * +* * +* 5. You may charge a reasonable copying fee for any distribution of this * +* Package. You may charge any fee you choose for support of this * +* Package. You may not charge a fee for this Package itself. However, * +* you may distribute this Package in aggregate with other (possibly * +* commercial) programs as part of a larger (possibly commercial) software * +* distribution provided that you do not advertise this Package as a * +* product of your own. You may embed this Package's interpreter within * +* an executable of yours (by linking); this shall be construed as a mere * +* form of aggregation, provided that the complete Standard Version of the * +* interpreter is so embedded. * +* * +* 6. The scripts and library files supplied as input to or produced as * +* output from the programs of this Package do not automatically fall * +* under the copyright of this Package, but belong to whoever generated * +* them, and may be sold commercially, and may be aggregated with this * +* Package. If such scripts or library files are aggregated with this * +* Package via the so-called "undump" or "unexec" methods of producing a * +* binary executable image, then distribution of such an image shall * +* neither be construed as a distribution of this Package nor shall it * +* fall under the restrictions of Paragraphs 3 and 4, provided that you do * +* not represent such an executable image as a Standard Version of this * +* Package. * +* * +* 7. C subroutines (or comparably compiled subroutines in other * +* languages) supplied by you and linked into this Package in order to * +* emulate subroutines and variables of the language defined by this * +* Package shall not be considered part of this Package, but are the * +* equivalent of input as in Paragraph 6, provided these subroutines do * +* not change the language in any way that would cause it to fail the * +* regression tests for the language. * +* * +* 8. Aggregation of this Package with a commercial distribution is always * +* permitted provided that the use of this Package is embedded; that is, * +* when no overt attempt is made to make this Package's interfaces visible * +* to the end user of the commercial distribution. Such use shall not be * +* construed as a distribution of this Package. * +* * +* 9. The name of the Copyright Holder may not be used to endorse or promote * +* products derived from this software without specific prior written * +* permission. * +* * +* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * +* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * +* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * +* * +* The End * +* * +\******************************************************************************/ + + +#include +#include +#include +#include +#include +#include "util.h" +#include "cudd.h" +#include "cuddInt.h" +#include "general.h" + +#define IsHigh(manager, node) HIGH(manager) == node +#define IsLow(manager, node) LOW(manager) == node +#define HIGH(manager) Cudd_ReadOne(manager) +#define LOW(manager) Cudd_Not(Cudd_ReadOne(manager)) +#define NOT(node) Cudd_Not(node) +#define GetIndex(node) Cudd_NodeReadIndex(node) +#define GetMVar(manager, index, value, varmap) equality(manager,index,value,varmap)//Cudd_bddIthVar(manager, index) +#define GetVar(manager, index) Cudd_bddIthVar(manager, index) +#define NewVar(manager) Cudd_bddNewVar(manager) +#define KillBDD(manager) Cudd_Quit(manager) +#define GetVarCount(manager) Cudd_ReadSize(manager) +#define DEBUGON _debug = 1 +#define DEBUGOFF _debug = 0 +#define RAPIDLOADON _RapidLoad = 1 +#define RAPIDLOADOFF _RapidLoad = 0 +#define SETMAXBUFSIZE(size) _maxbufsize = size +#define BDDFILE_ERROR -1 +#define BDDFILE_OTHER 0 +#define BDDFILE_SCRIPT 1 +#define BDDFILE_NODEDUMP 2 + +extern int _RapidLoad; +extern int _debug; +extern int _maxbufsize; + +typedef struct _bddfileheader { + FILE *inputfile; + int version; + int varcnt; + int bvarcnt; + int varstart; + int intercnt; + int filetype; +} bddfileheader; + +typedef struct + { +int nVal,nBit,init; +double * probabilities; +int * booleanVars; +} variable; + +typedef struct _namedvars { + int varcnt; + int varstart; + char **vars; + int *loaded; + double *dvalue; + int *ivalue; + void **dynvalue; + variable * mvars; + int * bVar2mVar; +} namedvars; + + +typedef struct _hisnode { + DdNode *key; + double dvalue; + int ivalue; + void *dynvalue; +} hisnode; + +typedef struct _hisqueue { + int cnt; + hisnode *thenode; +} hisqueue; + +typedef struct _nodeline { + char *varname; + char *truevar; + char *falsevar; + int nodenum; + int truenode; + int falsenode; +} nodeline; + +/* Initialization */ + +DdManager* simpleBDDinit(int varcnt); + +/* BDD Generation */ + +DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); +DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); + +DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader); +DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap); +DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline); +DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline); +DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper); +int getInterBDD(char *function); +char* getFileName(const char *function); +int GetParam(char *inputline, int iParam); +int LoadVariableData(namedvars varmap, char *filename); +int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename); + +/* Named variables */ + +namedvars InitNamedVars(int varcnt, int varstart); +namedvars InitNamedMultiVars(int varcnt, int varstart, int bvarcnt); +void EnlargeNamedVars(namedvars *varmap, int newvarcnt); +int AddNamedVarAt(namedvars varmap, const char *varname, int index); +int AddNamedVar(namedvars varmap, const char *varname); +int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varnamei, int *value); +void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue, void *dynvalue); +int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue, int ivalue, void *dynvalue); +int GetNamedVarIndex(const namedvars varmap, const char *varname); +int RepairVarcnt(namedvars *varmap); +char* GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node); +char* GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node); +int all_loaded(namedvars varmap, int disp); + +/* Traversal */ + +DdNode* HighNodeOf(DdManager *manager, DdNode *node); +DdNode* LowNodeOf(DdManager *manager, DdNode *node); + +/* Traversal - History */ + +hisqueue* InitHistory(int varcnt); +void ReInitHistory(hisqueue *HisQueue, int varcnt); +void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); +hisnode* GetNode(hisqueue *HisQueue, int varstart, DdNode *node); +int GetNodeIndex(hisqueue *HisQueue, int varstart, DdNode *node); +void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd); + +/* Save-load */ + +bddfileheader ReadFileHeader(char *filename); +int CheckFileVersion(const char *version); + +DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile); +DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current); +DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum); + +int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); +void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile); +void ExpandNodes(hisqueue *Nodes, int index, int nodenum); + +/* Export */ + +int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename); +int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); + +DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap); +hisnode* GetNodei1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); +void AddNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); +hisnode* GetNode1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); diff --git a/packages/cplint/approx/tptreefile.pl b/packages/cplint/approx/tptreefile.pl new file mode 100644 index 000000000..d0e724167 --- /dev/null +++ b/packages/cplint/approx/tptreefile.pl @@ -0,0 +1,727 @@ +%%% -*- Mode: Prolog; -*- +:-source. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% prefix-trees for managing a DNF +% remembers shortest prefix of a conjunction only (i.e. a*b+a*b*c results in a*b only, but b*a+a*b*c is not reduced) +% children are sorted, but branches aren't (to speed up search while keeping structure sharing from proof procedure) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +:- module(ptree,[init_ptree/1, + delete_ptree/1, + rename_ptree/2, + member_ptree/2, + enum_member_ptree/2, + insert_ptree/2, + delete_ptree/2, + edges_ptree/2, + count_ptree/2, + prune_check_ptree/2, + empty_ptree/1, + merge_ptree/3, + bdd_ptree/3, + bdd_ptree_map/4 + ]). +:-source. +:- use_module(library(tries), + [ + trie_open/1, + trie_close/1, + trie_stats/4, + trie_check_entry/3, + trie_get_entry/2, + trie_put_entry/3, + trie_remove_entry/1, + trie_usage/4, + trie_dup/2, + trie_join/2, + trie_traverse/2 + ]). + +:- use_module(library(ordsets), + [ + ord_subset/2 + ]). + +:- style_check(all). +%:- yap_flag(unknown,error). + +%:- use_module(flags,[problog_flag/2]). +:- ensure_loaded(library(lists)). +:- ensure_loaded(library(system)). + +% name lexicon external - internal +sym(1,tree1) :- !. +sym(2,tree2) :- !. +sym(3,tree3) :- !. +sym(N,AN) :- atomic_concat([tree,N],AN). + +%%%%%%%%%%%%%%%%%%%%%%%% +% ptree basics +%%%%%%%%%%%%%%%%%%%%%%%% + +init_ptree(ID) :- + sym(ID,Sym), + trie_open(Trie), + nb_setval(Sym, Trie). + +delete_ptree(ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), !, + trie_close(Trie), + trie_open(NewTrie), + nb_setval(Sym, NewTrie). +delete_ptree(_). + +rename_ptree(OldID,NewID) :- + sym(OldID,OldSym), + sym(NewID,NewSym), + nb_getval(OldSym, Trie), + nb_set_shared_val(NewSym, Trie). + +empty_ptree(ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_usage(Trie, 0, 0, 0). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% member +%%%%%%%%%%%%%%%%%%%%%%%% + +% non-backtrackable (to check) +member_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, List, _). + +% backtrackable (to list) +enum_member_ptree(ID,List) :- + sym(ID,Sym), + nb_getval(Sym, Tree), + trie_path(Tree, List). + +trie_path(Tree, List) :- + trie_traverse(Tree,Ref), + trie_get_entry(Ref, List). + +%%%%%%%%%%%%%%%%%%%%%%%% +% insert conjunction +%%%%%%%%%%%%%%%%%%%%%%%% +insert_ptree(true,ID) :- + sym(ID,Sym), + !, + nb_getval(Sym, Trie), + trie_close(Trie), + trie_open(NTrie), + trie_put_entry(NTrie, true, _). +insert_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_put_entry(Trie, List, _). + +%%%%%%%%%%%%%%%%%%%%%%%% +% delete conjunction +%%%%%%%%%%%%%%%%%%%%%%%% +delete_ptree(List,ID) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, List, Ref), + trie_remove_entry(Ref). + + +%%%%%%%% +% return list -Edges of all edge labels in ptree +% doesn't use any heuristic to order those for the BDD +% (automatic reordering has to do the job) +%%%%%%%%% +edges_ptree(ID,[]) :- + empty_ptree(ID), + !. +edges_ptree(ID,[]) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, true, _), + !. +edges_ptree(ID,Edges) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + %( + setof(X, trie_literal(Trie, X), Edges).%-> + /* true + ; + Edges=[] + ).*/ + +trie_literal(Trie, X) :- + trie_traverse(Trie,Ref), + trie_get_entry(Ref, List), + member(X, List). + +%%%%%%%% +% number of conjunctions in the tree +%%%%%%%%% + +count_ptree(ID,N) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_usage(Trie, N, _, _). + +%%%%%%%% +% check whether some branch of ptree is a subset of conjunction List +% useful for pruning the search for proofs (optional due to time overhead) +% currently not implemented, just fails +%%%%%%% + +prune_check_ptree(_List,_TreeID) :- + format(user,'FAIL: prune check currently not supported~n',[]), + flush_output(user), + fail. + +%%%%%%%%%%%%% +% merge two ptrees +% - take care not to loose proper prefixes that are proofs! +%%%%%%%%%%%%%%% + +merge_ptree(ID1,_,ID3) :- + sym(ID1,Sym1), + sym(ID3,Sym3), + nb_getval(Sym1, T1), + trie_check_entry(T1, true, _), + !, + trie_open(T3), + trie_put_entry(T3, true, _), + nb_setval(Sym3, T3). +merge_ptree(_,ID2,ID3) :- + sym(ID2,Sym2), + sym(ID3,Sym3), + nb_getval(Sym2, T2), + trie_check_entry(T2, true, _), + !, + trie_open(T3), + trie_put_entry(T3, true, _), + nb_setval(Sym3, T3). +merge_ptree(ID1,ID2,ID3) :- + sym(ID1,Sym1), + sym(ID2,Sym2), + sym(ID3,Sym3), + nb_getval(Sym1, T1), + nb_getval(Sym2, T2), + trie_dup(T1, T3), + trie_join(T3,T2), + nb_setval(Sym3, T3). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% write BDD info for given ptree to file +% - initializes leaf BDDs (=variables) first +% - then compresses ptree to exploit subtree sharing +% - bdd_pt/1 does the work on the structure itself +%%%%%%%%%%%%%%%%%%%%%%%% + +bdd_ptree(ID,FileBDD,FileParam) :- + bdd_ptree_script(ID,FileBDD,FileParam), + eraseall(map), + eraseall(vars). + +% version returning variable mapping +bdd_ptree_map(ID,FileBDD,FileParam,FileMapping) :- + bdd_ptree_script(ID,FileBDD,FileParam), + findall(X,recorded(map,X,_),Map), + add_probs(Map,Mapping), + tell(FileMapping), + write(Mapping),write('.'), + told, + eraseall(map), + eraseall(vars). + +add_probs([],[]). +add_probs([m(R,S,Num,Name)|Map],[m(R,S,Num,Name,Prob)|Mapping]) :- + user:rule_by_num(R,S,_N,Head,_Body), + user:get_probs(Head,Prob), + add_probs(Map,Mapping). + +% number of variables may be to high: +% counted on trie, but conversion to old tree representation +% transforms A*B+A to A (prefix-test) +bdd_ptree_script(ID,FileBDD,FileParam) :- + assert(v_num(0)), + edges_ptree(ID,Edges), + compute_nvars(Edges,0,NVars,0,NBVars), + tell(FileParam), + bdd_vars_script(Edges), + + flush_output, + + told, + length(Edges,_VarCount), + assert(c_num(1)), + bdd_pt(ID,CT),!, + c_num(NN), + IntermediateSteps is NN-1, + tell(FileBDD), + format('@BDD1~n~w~n~w~n~w~n~w~n',[NVars,NBVars,0,IntermediateSteps]), + output_compressed_script_only(CT),!, + + told, + retractall(c_num(_)), + retractall(v_num(_)), + retractall(compression(_,_)). + +compute_nvars([],NV,NV,NBV,NBV). + +compute_nvars([(_V,R,S)|T],NV0,NV1,NBV0,NBV1):- + (recorded(vars,v(R,S),_)-> + compute_nvars(T,NV0,NV1,NBV0,NBV1) + ; + recorda(vars,v(R,S),_), + NV2 is NV0+1, + user:rule_by_num(R,S,_N,Head,_Body), + length(Head,L), + NBV2 is NBV0+integer(ceiling(log(L)/log(2))), + compute_nvars(T,NV2,NV1,NBV2,NBV1) + ). + +% write parameter file by iterating over all var/not(var) occuring in the tree +/*bdd_vars_script(Edges) :- + bdd_vars_script(Edges,0). +*/ +bdd_vars_script([]). +%%%% Bernd, changes for negated ground facts +/* +bdd_vars_script([(_V,R,S)|B],N) :- + recorded(map,m(R,S,_Num,_NameA),_),!, + bdd_vars_script(B,N). +*/ +bdd_vars_script([(_V,R,S)|B]) :- + (recorded(map,m(R,S,_Number,_NameA),_)-> + true + ; + user:rule_by_num(R,S,_N,Head,_Body), + user:get_probs(Head,P), + get_var_name(R,S,_Number,NameA), + length(Head,NV), + format('@~w~n~d~n',[NameA,NV]), + print_probs(P) + ), + bdd_vars_script(B). + +print_probs([H]):-!, + format("~f~n",[H]). + +print_probs([H|T]):- + format("~f ",[H]), + print_probs(T). + + +%%%%%%%%%%%%%%%%%%%%%%%% +% find top level symbol for script +%%%%%%%%%%%%%%%%%%%%%%%% + +% special cases: variable-free formulae +bdd_pt(ID,false) :- + empty_ptree(ID), + !, + once(retractall(c_num(_))), + once(assert(c_num(2))). +bdd_pt(ID,true) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_check_entry(Trie, true, _), + !, + once(retractall(c_num(_))), + once(assert(c_num(2))). + +% general case: transform trie to nested tree structure for compression +bdd_pt(ID,CT) :- + sym(ID,Sym), + nb_getval(Sym, Trie), + trie_to_tree(Trie, Tree), + compress_pt(Tree,CT). + +trie_to_tree(Trie, Tree) :- + findall(Path,trie_path(Trie, Path), Paths), + add_trees(Paths, [], Tree). + +add_trees([], Tree, Tree). +add_trees([List|Paths], Tree0, Tree) :- + ins_pt(List, Tree0, TreeI), + add_trees(Paths, TreeI, Tree). + +ins_pt([],_T,[]) :- !. +ins_pt([A|B],[s(A1,AT)|OldT],NewT) :- + compare(Comp, A1, A), + (Comp == = -> + (AT == [] -> + NewT=[s(A1,AT)|OldT] + ; + NewT = [s(A1,NewAT)|OldT], + ins_pt(B, AT, NewAT)) + ; + Comp == > -> + NewT = [s(A1,AT)|Tree], + ins_pt([A|B], OldT, Tree) + ; + NewT = [s(A,BTree),s(A1,AT)|OldT], + ins_pt(B,[],BTree) + ). +ins_pt([A|B],[],[s(A,NewAT)]) :- + ins_pt(B,[],NewAT). + +%%%%%%%%%%%% +% BDD compression: alternates and- and or-levels to build BDD bottom-up +% each sub-BDD will be either a conjunction of a one-node BDD with some BDD or a disjunction of BDDs +% uses the internal database to temporarily store a map of components +%%%%%%%%%%%% + +% T is completely compressed and contains single variable +% i.e. T of form x12 or ~x34 +compress_pt(T,TT) :- + atom(T), + test_var_name(T), + !, + get_next_name(TT), + assertz(compression(TT,[T])). +% T is completely compressed and contains subtrees +% i.e. T of form 'L56' +compress_pt(T,T) :- + atom(T). +% T not yet compressed +% i.e. T is a tree-term (nested list & s/2 structure) +% -> execute one layer of compression, then check again +compress_pt(T,CT) :- + \+ atom(T), + and_or_compression(T,IT), + compress_pt(IT,CT). + +% transform tree-term T into tree-term CT where last two layers have been processed +% i.e. introduce names for subparts (-> Map) and replace (all occurrenes of) subparts by this names +and_or_compression(T,CT) :- + and_comp(T,AT), + or_comp(AT,CT). + +% replace leaves that are single child by variable representing father-AND-child +and_comp(T,AT) :- + all_leaves_pt(T,Leaves), + compression_mapping(Leaves,Map), + replace_pt(T,Map,AT). + +% replace list of siblings by variable representing their disjunction +or_comp(T,AT) :- + all_leaflists_pt(T,Leaves), + compression_mapping(Leaves,Map), + replace_pt(T,Map,AT). + +all_leaves_pt(T,L) :- + all(X,some_leaf_pt(T,X),L). + +some_leaf_pt([s(A,[])|_],s(A,[])). +some_leaf_pt([s(A,L)|_],s(A,L)) :- + not_or_atom(L). +some_leaf_pt([s(_,L)|_],X) :- + some_leaf_pt(L,X). +some_leaf_pt([_|L],X) :- + some_leaf_pt(L,X). + +all_leaflists_pt(L,[L]) :- + atomlist(L),!. +all_leaflists_pt(T,L) :- + all(X,some_leaflist_pt(T,X),L),!. +all_leaflists_pt(_,[]). + +some_leaflist_pt([s(_,L)|_],L) :- + atomlist(L). +some_leaflist_pt([s(_,L)|_],X) :- + some_leaflist_pt(L,X). +some_leaflist_pt([_|L],X) :- + some_leaflist_pt(L,X). + +not_or_atom(T) :- + ( + T=not(T0) + -> + atom(T0); + atom(T) + ). + +atomlist([]). +atomlist([A|B]) :- + not_or_atom(A), + atomlist(B). + +% for each subtree that will be compressed, add its name +% only introduce 'L'-based names when subtree composes elements, store these in compression/2 for printing the script +compression_mapping([],[]). +compression_mapping([First|B],[N-First|BB]) :- + ( + First = s((V,R,S),[]) % subtree is literal -> use variable's name x17 from map (add ~ for negative case) + -> + recorded(map,m(R,S,_Num,Tmp),_), %check + atomic_concat([Tmp,'-',V],N) + ; + (First = s(A,L),not_or_atom(L)) % subtree is node with single completely reduced child -> use next 'L'-based name + -> (get_next_name(N), + assertz(compression(N,s(A,L)))) + ; + (First = [L],not_or_atom(L)) % subtree is an OR with a single completely reduced element -> use element's name + -> N=L + /*, + recorded(refc,m(L,RefC),Ref), + erase(Ref), + RefC1 is RefC+1, + recorda(refc,m(L,RefC1),_)*/ + ; + (atomlist(First), % subtree is an OR with only (>1) completely reduced elements -> use next 'L'-based name + get_next_name(N), + assertz(compression(N,First))) + ), + compression_mapping(B,BB). + +increase_counts([]). + +increase_counts([H|T]):- + recorded(refc,m(H,RC),Ref), + erase(Ref), + RC1 is RC+1, + recorda(refc,m(H,RC1),_), + increase_counts(T). + +compute_or([A],Node0,Node1):- + recorded(mapnodes,m(A,Node),_), + or(Node0,Node,Node1). + +compute_or([A,B|T],Node0,Node1):- + recorded(mapnodes,m(A,Node),_), + or(Node0,Node,Node2), + compute_or([B|T],Node2,Node1). + + +% replace_pt(+T,+Map,-NT) +% given the tree-term T and the Map of Name-Subtree entries, replace each occurence of Subtree in T with Name -> result NT +replace_pt(T,[],T). +replace_pt([],_,[]). +replace_pt(L,M,R) :- + atomlist(L), + member(R-L,M), + !. +replace_pt([L|LL],[M|MM],R) :- + replace_pt_list([L|LL],[M|MM],R). + +replace_pt_list([T|Tree],[M|Map],[C|Compr]) :- + replace_pt_single(T,[M|Map],C), + replace_pt_list(Tree,[M|Map],Compr). +replace_pt_list([],_,[]). + +replace_pt_single(s(A,T),[M|Map],Res) :- + atomlist(T), + member(Res-s(A,T),[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],s(A,Res)) :- + atomlist(T), + member(Res-T,[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],Res) :- + member(Res-s(A,T),[M|Map]), + !. +replace_pt_single(s(A,T),[M|Map],s(A,TT)) :- + replace_pt_list(T,[M|Map],TT). +replace_pt_single(A,_,A) :- + not_or_atom(A). + +output_compressed_script_only(false) :- + !, + format('L1 = FALSE~nL1~n',[]). +output_compressed_script_only(true) :- + !, + format('L1 = TRUE~nL1~n',[]). +output_compressed_script_only(T) :- + once(retract(compression(Short,Long))), + assertz(compression(Short,Long)), + (T = Short -> + format('~w = ',[Short]), + format_compression_script_only(Long), + format('~w~n',[Short]) + ; + format('~w = ',[Short]), + format_compression_script_only(Long), + output_compressed_script_only(T) + ). + +format_compression_script_only(s((V,R,S),B0)) :- + recorded(map,m(R,S,_Num,C),_), + atomic_concat([C,'-',V],C1), + format('~w * ~w~n',[C1,B0]). + +format_compression_script_only([A]) :- + format('~w~n',[A]). +format_compression_script_only([A,B|C]) :- + format('~w + ',[A]), + format_compression_script_only([B|C]). + + +%%%%%%%%%%%% +% output for script +% input argument is compressed tree, i.e. true/false or name assigned in last compression step +%%%%%%%%%%%% +output_compressed_script(false) :- + !. + %format('L1 = FALSE~nL1~n',[]). +output_compressed_script(true) :- + !. + %format('L1 = TRUE~nL1~n',[]). +% for each name-subtree pair, write corresponding line to script, e.g. L17 = x4 * L16 +% stop after writing definition of root (last entry in compression/2), add it's name to mark end of script +output_compressed_script(T) :- + once(retract(compression(Short,Long))), + (T = Short -> + % format('~w = ',[Short]), + format_compression_script(Long,Short) + % format('~w~n',[Short]) + ; + % format('~w = ',[Short]), + format_compression_script(Long,Short), + output_compressed_script(T)). + +format_compression_script(s((V,R,S),B0),Short) :-!, + % checkme + recorded(map,m(R,S,_Num,C),_), + atomic_concat([C,'-',V],C1), + recorded(mapnodes,m(C1,Node1),_), + recorded(mapnodes,m(B0,Node2),_), + % format('~w * ~w~n',[C1,B0]), + and(Node1,Node2,Node), + recorda(mapnodes,m(Short,Node),_), + recorded(refc,m(C1,RefC1),Ref1), + recorded(refc,m(B0,RefC2),Ref2), + erase(Ref1), + erase(Ref2), + RefC11 is RefC1-1, + RefC21 is RefC2-1, + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(C1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(B0,RefC21),_) + ). + +format_compression_script([H1],Short):-!, + % format('~w~n',[A]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + recorda(mapnodes,m(Short,Node1),_). + +format_compression_script([H1,H2],Short):-!, + % format('~w + ~w~n',[H1,H2]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + recorded(mapnodes,m(H2,Node2),_), + recorded(refc,m(H2,RefC2),Ref2), + erase(Ref2), + RefC21 is RefC2-1, + or(Node1,Node2,Node), + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(H2,RefC21),_) + ), + recorda(mapnodes,m(Short,Node),_). + +format_compression_script([H1,H2,H3|T],Short):- + %format('~w + ~w +',[H1,H2]), + recorded(mapnodes,m(H1,Node1),_), + recorded(refc,m(H1,RefC1),Ref1), + erase(Ref1), + RefC11 is RefC1-1, + recorded(mapnodes,m(H2,Node2),_), + recorded(refc,m(H2,RefC2),Ref2), + erase(Ref2), + RefC21 is RefC2-1, + or(Node1,Node2,Node), + (RefC11 =:=0-> + deref(Node1) + ; + recorda(refc,m(H1,RefC11),_) + ), + (RefC21 =:=0-> + deref(Node2) + ; + recorda(refc,m(H2,RefC21),_) + ), + format_compression_script1([H3|T],Node,Short). + +format_compression_script1([A],Node1,Short) :-!, +% format('~w~n',[A]), + recorded(mapnodes,m(A,Node2),_), + recorded(refc,m(A,RefC),Ref), + erase(Ref), + or(Node1,Node2,Node), + deref(Node1), + recorda(mapnodes,m(Short,Node),_), + RefC1 is RefC-1, + (RefC1=:=0-> + deref(Node2) + ; + recorda(refc,m(A,RefC1),_) + ). + +format_compression_script1([A,B|C],Node1,Short) :- + format('~w + ',[A]), + recorded(mapnodes,m(A,Node2),_), + recorded(refc,m(A,RefC),Ref), + erase(Ref), + or(Node1,Node2,Node), + deref(Node1), + RefC1 is RefC-1, + (RefC1=:=0-> + deref(Node2) + ; + recorda(refc,m(A,RefC1),_) + ), + format_compression_script1([B|C],Node,Short). + +%%%%%%%%%%%%%%%%%%%%%%%% +% auxiliaries for translation to BDD +%%%%%%%%%%%%%%%%%%%%%%%% + +% prefix the current counter with "L" +get_next_name(Name) :- + retract(c_num(N)), + NN is N+1, + assert(c_num(NN)), + atomic_concat('L',N,Name). + +get_next_var_id(N,Name) :- + retract(v_num(N)), + NN is N+1, + assert(v_num(NN)), + atomic_concat('x',N,Name). + +% create BDD-var as fact id prefixed by x +% learning.yap relies on this format! +% when changing, also adapt test_var_name/1 below +get_var_name(R,S,Number,NameA) :- + get_next_var_id(Number,NameA), + recorda(map,m(R,S,Number,NameA),_). + +% test used by base case of compression mapping to detect single-variable tree +% has to match above naming scheme +test_var_name(T) :- + atomic_concat(x,_,T). diff --git a/packages/cplint/approx/utility.pl b/packages/cplint/approx/utility.pl new file mode 100644 index 000000000..3079235fe --- /dev/null +++ b/packages/cplint/approx/utility.pl @@ -0,0 +1,367 @@ +/*============================================================================== + * LPAD and CP-Logic reasoning suite + * File: parsing.pl + * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) + * Copyright (c) 2009, Stefano Bragaglia + *============================================================================*/ + +:- dynamic rule/4, def_rule/2. + +% :- source. +% :- yap_flag(single_var_warnings, on). + + + + + +/* BUILTIN PREDICATES + * ------------------ + * This section declares the builtin predicates. + */ +builtin(_A is _B). +builtin(_A > _B). +builtin(_A < _B). +builtin(_A >= _B). +builtin(_A =< _B). +builtin(_A =:= _B). +builtin(_A =\= _B). +builtin(true). +builtin(false). +builtin(_A = _B). +builtin(_A==_B). +builtin(_A\=_B). +builtin(_A\==_B). +builtin(length(_L, _N)). +builtin(member(_El, _L)). +builtin(average(_L, _Av)). +builtin(max_list(_L, _Max)). +builtin(min_list(_L, _Max)). +builtin(nth0(_, _, _)). +builtin(nth(_, _, _)). +builtin(eraseall(_Id)). +builtin(recordz(_Id, _Item, _)). +builtin(recordzifnot(_Id, _Item, _)). + + + +member_eq(Item, [Head|_Tail]) :- + Item==Head, !. + +member_eq(Item, [_Head|Tail]) :- + member_eq(Item, Tail). + + + +not_already_present_with_a_different_head(_HeadId, _RuleId, _Subst, []). + +not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(HeadId1, RuleId, Subst1)|Tail]) :- + not_different(HeadId, HeadId1, Subst, Subst1), !, + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). + +not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(_HeadId1, RuleId1, _Subst1)|Tail]) :- + RuleId \== RuleId1, + not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). + + + +not_different(_HeadId, _HeadId1, Subst, Subst1) :- + Subst \= Subst1, !. + +not_different(HeadId, HeadId1, Subst, Subst1) :- + HeadId \= HeadId1, !, + dif(Subst, Subst1). + +not_different(HeadId, HeadId, Subst, Subst). + + + +get_groundc([], [], [], P, P) :- !. + +get_groundc([H|T], [H|T1], TV, P0, P1) :- + ground(H), !, + H=(N, R, S), + rule_by_num(R, S, _N, Head, _Body), + nth0(N, Head, (_A:P)), + P2 is P0*P, + get_groundc(T, T1, TV, P2, P1). + +get_groundc([H|T], T1, [H|TV], P0, P1) :- + get_groundc(T, T1, TV, P0, P1). + +get_prob([], P, P) :- !. + +get_prob([H|T], P0, P1) :- + H=(N, R, S), + rule_by_num(R, S, _N, Head, _Body), + nth0(N, Head, (_A:P)), + P2 is P0*P, + get_prob(T, P2, P1). + + + + +find_rulec(H, (R, S, N), Body, C, P) :- + rule(H, P, N, R, S, _NH, _Head, Body), + not_already_present_with_a_different_head(N, R, S, C). + + + +/* var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) + * ---------------------------------------------------------------------------------- + * This tail recursive predicate converts a list of couples (Rule, Subst) into a + * list of triples (Index, Count, Probs). + * Rule and Subst are the index of their equivalent rule and substitution. + * Index is a progressive identifier starting from 0. + * Count is the number of head atoms and Probs is the vector of their + * probabilities. + * + * INPUT + * - Couples: list of couples to convert. + * + * OUTPUT + * - Triples: list of equivalent triples. + */ +var2numbers([], _N, []). + +var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) :- + find_probs(Rule, Subst, Probs), + length(Probs, Heads), + Next is Index+1, + var2numbers(CoupleTail, Next, TripleTail). + + + +/* build_formula(ListC, Formula, VarIn, VarOut) + * -------------------------------------------- + * This predicate parses a given list of C sets with a given list of variables + * and returns the equivalent formula with its list of variables. + * + * Note: each Formula is expressed in the form: [Term1, ..., TermN], where each + * term is expressed in the form: [Factor1, ..., FactorM], where each + * factor is hence expressed in the form: (Var, Name). + * Finally, Var is the index of the multivalued variable Var, and Value is + * the index of its value. + * + * INPUT + * - ListC: given list of C sets. + * - VarIn: list of variables pertaining to ListC. + * + * OUTPUT + * - Formula: the formula equivalent to ListC. + * - VarOut: list of variables pertaining to Formula. + */ +build_formula([], [], Var, Var, Count, Count). +%% Closing condition: stop if no more terms (current Var is final Var, current Count is final Count) + +build_formula([D|TD], [F|TF], VarIn, VarOut, C0, C1) :- + length(D, NC), + C2 is C0+NC, + reverse(D, D1), + build_term(D1, F, VarIn, Var1), + build_formula(TD, TF, Var1, VarOut, C2, C1). + %% Recursive call: procedd to next terms, building rest of formula and handling vars and count. + +build_formula([], [], Var, Var). + +build_formula([D|TD], [F|TF], VarIn, VarOut) :- + build_term(D, F, VarIn, Var1), + build_formula(TD, TF, Var1, VarOut). + + + +build_term([], [], Var, Var). + +build_term([(_, pruned, _)|TC], TF, VarIn, VarOut) :- !, + build_term(TC, TF, VarIn, VarOut). + +build_term([(N, R, S)|TC], [[NVar, N]|TF], VarIn, VarOut) :- + (nth0_eq(0, NVar, VarIn, (R, S)) -> + Var1=VarIn; + append(VarIn, [(R, S)], Var1), + length(VarIn, NVar)), + build_term(TC, TF, Var1, VarOut). + + + +find_probs(R, S, Probs) :- + rule_by_num(R, S, _N, Head, _Body), + get_probs(Head, Probs). + + + +get_probs(uniform(_A:1/Num, _P, _Number), ListP) :- + Prob is 1/Num, + list_el(Num, Prob, ListP). + +get_probs([], []). + +get_probs([_H:P|T], [P1|T1]) :- + P1 is P, + get_probs(T, T1). + + + +list_el(0, _P, []) :- !. + +list_el(N, P, [P|T]) :- + N1 is N-1, + list_el(N1, P, T). + + + +/* nth0_eq(PosIn, PosOut, List, Elem) + * ---------------------------------- + * This predicate searches for an element that matches with the given one in the + * given list, starting from the given position, and returns its position. + * + * INPUT + * - PosIn: initial position. + * - List: list to parse. + * - Elem: element to match. + * + * OUTPUT + * - PosOut: next position of a matching element. + */ +nth0_eq(N, N, [H|_T], Elem) :- + H==Elem, !. + +nth0_eq(NIn, NOut, [_H|T], Elem) :- + N1 is NIn+1, + nth0_eq(N1, NOut, T, Elem). + + + +list2and([X], X) :- + X\=(_, _), !. + +list2and([H|T], (H, Ta)) :- !, + list2and(T, Ta). + + + +list2or([X], X) :- + X\=;(_, _), !. + +list2or([H|T], (H ; Ta)) :- !, + list2or(T, Ta). + + + +choose_clausesc(_G, C, [], C). + +choose_clausesc(CG0, CIn, [D|T], COut) :- + member((N, R, S), D), + choose_clauses_present(N, R, S, CG0, CIn, COut, T). + +choose_clausesc(G0, CIn, [D|T], COut) :- + member((N, R, S), D), + new_head(N, R, S, N1), + \+ already_present(N1, R, S, CIn), + \+ already_present(N1, R, S, G0), + impose_dif_cons(R, S, CIn), + choose_clausesc(G0, [(N1, R, S)|CIn], T, COut). + + + +choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- + already_present_with_a_different_head_ground(N, R, S, CG0), !, + choose_clausesc(CG0, CIn, T, COut). + +choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- + already_present_with_a_different_head(N, R, S, CIn), + choose_a_head(N, R, S, CIn, C1), + choose_clausesc(CG0, C1, T, COut). + + + +/* new_head(N, R, S, N1) + * --------------------- + * This predicate selects an head for rule R different from N with substitution + * S and returns it in N1. + */ +new_head(N, R, S, N1) :- + rule_by_num(R, S, Numbers, Head, _Body), + Head\=uniform(_, _, _), !, + nth0(N, Numbers, _Elem, Rest), + member(N1, Rest). + +new_head(N, R, S, N1) :- + rule_uniform(_A, R, S, Numbers, 1/Tot, _L, _Number, _Body), + listN(0, Tot, Numbers), + nth0(N, Numbers, _Elem, Rest), + member(N1, Rest). + + + +/* already_present(N, R, S, [(N, R, SH)|_T]) + * ----------------------------------------- + * This predicate checks if a rule R with head N and selection S (or one of its + * generalizations is in C) is already present in C. + */ +already_present(N, R, S, [(N, R, SH)|_T]) :- + S=SH. + +already_present(N, R, S, [_H|T]) :- + already_present(N, R, S, T). + + + +already_present_with_a_different_head(N, R, S, [(NH, R, SH)|_T]) :- + \+ \+ S=SH, NH \= N. + +already_present_with_a_different_head(N, R, S, [_H|T]) :- + already_present_with_a_different_head(N, R, S, T). + +already_present_with_a_different_head_ground(N, R, S, [(NH, R, SH)|_T]) :- + S=SH, NH \= N. + +already_present_with_a_different_head_ground(N, R, S, [_H|T]) :- + already_present_with_a_different_head_ground(N, R, S, T). + + + +impose_dif_cons(_R, _S, []) :- !. + +impose_dif_cons(R, S, [(_NH, R, SH)|T]) :- !, + dif(S, SH), + impose_dif_cons(R, S, T). + +impose_dif_cons(R, S, [_H|T]) :- + impose_dif_cons(R, S, T). + + + +/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) + * -------------------------------------------------------- + * This predicate chooses and returns an head. + * It instantiates a more general rule if it is contained in C with a different + * head. + */ +choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) :- + S=SH, + dif(N, NH). + +/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) + * -------------------------------------------------------------------- + * This predicate chooses and returns an head. + * It instantiates a more general rule if it is contained in C with a different + * head. + * It ensures the same ground clause is not generated again. + */ +choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) :- + \+ \+ S=SH, S\==SH, + dif(N, NH), + dif(S, SH). + +choose_a_head(N, R, S, [H|T], [H|T1]) :- + choose_a_head(N, R, S, T, T1). + + + +listN(N, N, []) :- !. + +listN(NIn, N, [NIn|T]) :- + N1 is NIn+1, + listN(N1, N, T). + + diff --git a/packages/cplint/cplint_yap.c b/packages/cplint/cplint_yap.c index 51ea7511d..350ad5491 100644 --- a/packages/cplint/cplint_yap.c +++ b/packages/cplint/cplint_yap.c @@ -123,7 +123,7 @@ static int compute_prob(void) char * names[1000]; GHashTable * nodes; /* hash table that associates nodes with their probability if already computed, it is defined in glib */ - Cudd_ReorderingType order; + //Cudd_ReorderingType order; arg1=YAP_ARG1; arg2=YAP_ARG2; arg3=YAP_ARG3; diff --git a/packages/cplint/lpadsld.pl b/packages/cplint/lpadsld.pl index a9578f9ad..6dca77f63 100644 --- a/packages/cplint/lpadsld.pl +++ b/packages/cplint/lpadsld.pl @@ -70,7 +70,7 @@ solve(GoalsList,Prob,CPUTime1,CPUTime2,WallTime1,WallTime2):- CPUTime1 is CT1/1000, statistics(walltime,[_,WT1]), WallTime1 is WT1/1000, - print_mem, + %print_mem, build_formula(L,Formula,[],Var,0,Conj), length(L,ND), length(Var,NV), @@ -87,7 +87,7 @@ solve(GoalsList,Prob,CPUTime1,CPUTime2,WallTime1,WallTime2):- statistics(walltime,[_,WT2]), WallTime2 is WT2/1000 ; - print_mem, + %print_mem, Prob=0.0, statistics(cputime,[_,CT1]), CPUTime1 is CT1/1000, @@ -96,9 +96,10 @@ solve(GoalsList,Prob,CPUTime1,CPUTime2,WallTime1,WallTime2):- CPUTime2 =0.0, statistics(walltime,[_,WT2]), WallTime2 =0.0 - ),!, + ),!. + /*, format(user_error,"~nMemory after inference~n",[]), - print_mem. + print_mem.*/ si(GoalsList,ProbL,ProbU,CPUTime):- statistics(cputime,[_,_]), @@ -239,7 +240,7 @@ solve_cond(Goals,Evidence,Prob):- (setof(DerivE,find_deriv(Evidence,DerivE),LDupE)-> rem_dup_lists(LDupE,[],LE), (setof(DerivGE,find_deriv_GE(LE,Goals,DerivGE),LDupGE)-> - print_mem, + %print_mem, rem_dup_lists(LDupGE,[],LGE), build_formula(LE,FormulaE,[],VarE), var2numbers(VarE,0,NewVarE), @@ -249,15 +250,16 @@ solve_cond(Goals,Evidence,Prob):- call_compute_prob(NewVarGE,FormulaGE,ProbGE), Prob is ProbGE/ProbE ; - print_mem, + %print_mem, Prob=0.0 ) ; - print_mem, + %print_mem, Prob=undefined - ), + ). + /*, format(user_error,"~nMemory after inference~n",[]), - print_mem. + print_mem. */ sci(Goals,Evidence,ProbL,ProbU,CPUTime):- statistics(cputime,[_,_]), diff --git a/packages/cplint/slg.pl b/packages/cplint/slg.pl index 1ccf75983..2580a2b8d 100644 --- a/packages/cplint/slg.pl +++ b/packages/cplint/slg.pl @@ -29,7 +29,7 @@ % Sicstus /* Begin Sicstus specific code */ - append([],L,L). +/* append([],L,L). append([X|L1],L2,[X|L3]) :- append(L1,L2,L3). member(X,[X|_]). @@ -37,7 +37,7 @@ memberchk(X,[X|_]) :- !. memberchk(X,[_|L]) :- memberchk(X,L). - +*/ :- dynamic 'slg$prolog'/1, 'slg$tab'/2. :- dynamic slg_expanding/0. :- dynamic wfs_trace/0. diff --git a/packages/cplint/testcpl.pl b/packages/cplint/testcpl.pl index ed840be4f..00dfaac84 100644 --- a/packages/cplint/testcpl.pl +++ b/packages/cplint/testcpl.pl @@ -26,6 +26,7 @@ t:- format("~nTesting cpl.yap~n~n",[]), files(F), statistics(runtime,[_,_]), + set(ground_body,false), test_files(F,ground_body(false)), statistics(runtime,[_,T]), T1 is T /1000, diff --git a/packages/cplint/testlpadvel.pl b/packages/cplint/testlpadvel.pl index 2f54df1f5..65b717851 100644 --- a/packages/cplint/testlpadvel.pl +++ b/packages/cplint/testlpadvel.pl @@ -9,8 +9,8 @@ Use to execute the test */ -%:-use_module(library(lpadvel)). -:-use_module(lpadvelor). +:-use_module(library(lpadvel)). +%:-use_module(lpadvelor). epsilon(0.000001). diff --git a/packages/cplint/testsemlpad.pl b/packages/cplint/testsemlpad.pl index eeb43d47d..84042765e 100644 --- a/packages/cplint/testsemlpad.pl +++ b/packages/cplint/testsemlpad.pl @@ -68,7 +68,7 @@ test_all(F,[H|T]):- files_modes([ exapprox, exrange, -threesideddice, +%threesideddice, %mendels, %ok only with grounding=variables coin2, ex,exist,exist1 diff --git a/packages/cplint/testsemlpadsld.pl b/packages/cplint/testsemlpadsld.pl index 049e017ac..4409f42ee 100644 --- a/packages/cplint/testsemlpadsld.pl +++ b/packages/cplint/testsemlpadsld.pl @@ -68,7 +68,7 @@ test_all(F,[H|T]):- files_modes([ exapprox, exrange, -threesideddice, +%threesideddice, %mendels, school_simple, coin2, @@ -78,7 +78,7 @@ ex]). files_variables([ exapprox, exrange, -threesideddice, +%threesideddice, mendels, %school_simple, coin2, @@ -95,8 +95,8 @@ test((s([a(1)],P),close_to(P,0.2775)),exrange,_). test((s([a(2)],P),close_to(P,0.36)),exrange,_). test((s([on(0,1)],P),close_to(P,0.333333333333333)),threesideddice,_). -test((s([on(1,1)],P),close_to(P,0.222222222222222)),threesideddice,_). -test((s([on(2,1)],P),close_to(P,0.148148147703704)),threesideddice,_). +%test((s([on(1,1)],P),close_to(P,0.222222222222222)),threesideddice,_). +%test((s([on(2,1)],P),close_to(P,0.148148147703704)),threesideddice,_). test((sc([on(2,1)],[on(0,1)],P),close_to(P,0.222222222222222)),threesideddice,_). test((sc([on(2,1)],[on(1,1)],P),close_to(P,0.333333333333333)),threesideddice,_). From 92b9be2dc8ea31de9c9e12028bdb0ff3fb1c5bcd Mon Sep 17 00:00:00 2001 From: RIGUZZI FABRIZIO - Dipartimento di Ingegneria Date: Thu, 18 Mar 2010 18:17:54 +0100 Subject: [PATCH 3/6] removed .svn dir --- packages/cplint/approx/.svn/all-wcprops | 77 - packages/cplint/approx/.svn/entries | 446 ----- packages/cplint/approx/.svn/format | 1 - .../.svn/text-base/INSTALL.txt.svn-base | 5 - .../.svn/text-base/bestfirst.pl.svn-base | 451 ----- .../approx/.svn/text-base/bestk.pl.svn-base | 528 ----- .../approx/.svn/text-base/deepdyn.pl.svn-base | 352 ---- .../approx/.svn/text-base/deepit.pl.svn-base | 352 ---- .../approx/.svn/text-base/exact.pl.svn-base | 235 --- .../.svn/text-base/exact_mem.pl.svn-base | 189 -- .../.svn/text-base/montecarlo.pl.svn-base | 275 --- .../approx/.svn/text-base/params.pl.svn-base | 122 -- .../approx/.svn/text-base/parsing.pl.svn-base | 344 ---- .../.svn/text-base/tptreefile.pl.svn-base | 727 ------- .../approx/.svn/text-base/utility.pl.svn-base | 367 ---- .../approx/simplecuddLPADs/.svn/all-wcprops | 47 - .../approx/simplecuddLPADs/.svn/entries | 273 --- .../cplint/approx/simplecuddLPADs/.svn/format | 1 - .../.svn/text-base/Makefile.svn-base | 55 - .../.svn/text-base/ProblogBDD.c.svn-base | 871 -------- .../.svn/text-base/ProblogBDDclus.c.svn-base | 895 --------- .../.svn/text-base/general.c.svn-base | 234 --- .../.svn/text-base/general.h.svn-base | 159 -- .../.svn/text-base/simplecudd.c.svn-base | 1747 ----------------- .../.svn/text-base/simplecudd.h.svn-base | 306 --- 25 files changed, 9059 deletions(-) delete mode 100644 packages/cplint/approx/.svn/all-wcprops delete mode 100644 packages/cplint/approx/.svn/entries delete mode 100644 packages/cplint/approx/.svn/format delete mode 100644 packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/bestk.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/deepit.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/exact.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/params.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/parsing.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base delete mode 100644 packages/cplint/approx/.svn/text-base/utility.pl.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/entries delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/format delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.c.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base delete mode 100644 packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base diff --git a/packages/cplint/approx/.svn/all-wcprops b/packages/cplint/approx/.svn/all-wcprops deleted file mode 100644 index 5bde043e7..000000000 --- a/packages/cplint/approx/.svn/all-wcprops +++ /dev/null @@ -1,77 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/cplint/!svn/ver/2160/cplint/trunk/cplint_new/approx_src -END -bestfirst.pl -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/bestfirst.pl -END -bestk.pl -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/bestk.pl -END -deepdyn.pl -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/deepdyn.pl -END -deepit.pl -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/deepit.pl -END -INSTALL.txt -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/cplint/!svn/ver/2160/cplint/trunk/cplint_new/approx_src/INSTALL.txt -END -exact_mem.pl -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/exact_mem.pl -END -montecarlo.pl -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/montecarlo.pl -END -params.pl -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/params.pl -END -parsing.pl -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/parsing.pl -END -tptreefile.pl -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/tptreefile.pl -END -utility.pl -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/utility.pl -END -exact.pl -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/exact.pl -END diff --git a/packages/cplint/approx/.svn/entries b/packages/cplint/approx/.svn/entries deleted file mode 100644 index f741cd769..000000000 --- a/packages/cplint/approx/.svn/entries +++ /dev/null @@ -1,446 +0,0 @@ -9 - -dir -2205 -https://ds.ing.unife.it/svn/cplint/cplint/trunk/cplint_new/approx_src -https://ds.ing.unife.it/svn/cplint - - - -2010-03-15T10:52:08.979119Z -2160 -friguzzi - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -8b881860-fc2d-0410-9739-81b0d24abadf - - - - - - -0 - -bestfirst.pl -file - - - - -2010-03-15T10:10:51.000000Z -cc0ab0375af7a0d3f1075283af40bb42 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -16349 - -deepdyn.pl -file - - - - -2010-03-15T10:12:51.000000Z -bae676b92cbfdf9e1a534312d701c56b -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -12041 - -bestk.pl -file - - - - -2010-03-15T10:12:37.000000Z -10bc1754eaa5ed354b87686f4b44ef42 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -19626 - -deepit.pl -file - - - - -2010-03-15T10:13:06.000000Z -7bf0b9c071d33fcf01ed31fc2a21dfc8 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -12009 - -INSTALL.txt -file - - - - -2010-03-15T10:51:58.000000Z -995b2f3c1195b166dd28147e3a36db71 -2010-03-15T10:52:08.979119Z -2160 -friguzzi - - - - - - - - - - - - - - - - - - - - - -354 - -exact_mem.pl -file - - - - -2010-03-15T10:09:31.000000Z -a83ce974957436d11f61969a5024dd99 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -5546 - -montecarlo.pl -file - - - - -2010-03-15T10:09:31.000000Z -d97412d0fe41b3af1357e5a01d7e04b1 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -9140 - -utility.pl -file - - - - -2010-03-15T10:09:31.000000Z -26ae6e67bf10751c653519db4037e3d2 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -9698 - -simplecuddLPADs -dir - -params.pl -file - - - - -2010-03-15T10:09:31.000000Z -1ef52cf23908247415d2852252ad766a -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -2999 - -parsing.pl -file - - - - -2010-03-15T10:09:31.000000Z -7b1ae7dc7abf91883ec268a0d45744a6 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -9148 - -tptreefile.pl -file - - - - -2010-03-15T10:09:31.000000Z -02811461bc732d74a68b1b8572116370 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -18024 - -exact.pl -file - - - - -2010-03-15T10:13:20.000000Z -f2bd2e1315dc70c787f3abd14af17539 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -6731 - diff --git a/packages/cplint/approx/.svn/format b/packages/cplint/approx/.svn/format deleted file mode 100644 index ec635144f..000000000 --- a/packages/cplint/approx/.svn/format +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base b/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base deleted file mode 100644 index 1af57a681..000000000 --- a/packages/cplint/approx/.svn/text-base/INSTALL.txt.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -To use the algorithms, you have to compile simplecudd for LPADs in folder -simplecuddLPADs. Modify the makefile provided to suit your machine and run -make, make install. Please note that glu is a library that includes cudd and -that is distributed with vis http://vlsi.colorado.edu/~vis/. -Instead of linking with libglu.a, you can link with libcudd-ver.a. diff --git a/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base b/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base deleted file mode 100644 index 8f5cf20ee..000000000 --- a/packages/cplint/approx/.svn/text-base/bestfirst.pl.svn-base +++ /dev/null @@ -1,451 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File best.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(system)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(tptreefile). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) - * ------------------------------------------------------ - * This predicate computes the probability of a given list of goals using an - * iterative deepening, probability bounded algorithm. - * It also returns the number of handled BDDs and the CPUTime spent performing - * resolution and spent handling the BDDs. - * - * Note: when their derivation is cut, negative goals are added to the head of - * the goals' list to be solved during the following iteration. - * - * INPUT - * - GoalsList: given list of goal to work on. It can contains variables: the - * predicate returns in backtracking all the solutions and their equivalent - * lower and upper bound probability. - * - * OUTPUT - * - ProbLow: resulting lower bound probability for the given list of goals. - * - ProbUp: resulting upper bound probability for the given list of goals. - * - Count: number of BDDs generated by the algorithm. - * - ResTime: CPU time spent on performing resolution. - * - BddTime: CPU time spent on handling BDDs. - */ -solve(Goals, ProbLow, ProbUp, Count, ResTime, BddTime) :- - setting(k, K), - setting(min_error, MinError), - setting(prob_step, ProbStep), - - ProbStepLog is log(ProbStep), - - assert(low(0, 0.0)), - assert(up(1.0)), - init_ptree(1), - - % NB: log(1.0) == 0.0 !!! - bestfirst([0.0-([], [], Goals)], 0, K, MinError, ProbStepLog, ProbLow, ProbUp, 0, Count, 0, ResTime, 0, BddTime), - - delete_ptree(1), - retract(low(_, _)), - retract(up(_)). - - - -/* bestfirst(GoalsList, Number, Amount, MinError, ProbStep, - * LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) - * ----------------------------------------------------------------------------- - * This recursive supporting predicate performs resolution for current iteration, - * handles equivalent BDDs (lower and upper one) and calls itself if the current - * probability error is still bigger than the given minimum error. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - FoundList: given list of achieved solutions. - * - Amount: max number of solution considered by each iteration. - * - MinError: minimum error (closing condition). - * - ProbStep: probability step. - * - Count0: number of BDDs already handled by the algorithm. - * - ResTime0: cpu time already spent on performing resolution. - * - BddTime0: cpu time already spent on handling BDDs. - * - * OUTPUT - * - LowerProb1: resulting lower bound probability for the given list of goals. - * - UpperProb1: resulting upper bound probability for the given list of goals. - * - Count1: number of BDDs handled. - * - ResTime1: cpu time spent on performing resolution. - * - BddTime1: cpu time spent on handling BDDs. - */ -bestfirst(GoalsList, Number, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count0, Count1, ResTime0, ResTime1, BddTime0, BddTime1) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - - % Performing resolution... - main(GoalsList, Amount, ProbStep, List), - - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime2 is ResTime0 + ElapResTime/1000, - - % Building and solving equivalent bdds... - init_ptree(2), - init_ptree(3), - separate(List, [], LowerList0, [], UpperList, [], Incomplete), - insert_list_ptree(LowerList0, 1), - insert_list_ptree(UpperList, 2), - merge_ptree(1,2,3), - - length(LowerList0, DeltaLow), - Next is Number + DeltaLow, - eval_lower(Next, ProbLow), - - length(UpperList, DeltaUp), - Temp is Next + DeltaUp, - eval_upper(Temp, ProbUp), - - delete_ptree(2), - delete_ptree(3), - - % Taking elapsed times... - Count2 is Count0 + 2, - statistics(walltime, [_, ElapBddTime]), - BddTime2 is BddTime0 + (ElapBddTime / 1000), - - % Is the current error lower than the minimum error? - (ProbUp - ProbLow < MinError -> - % Setting output parameters' values... - LowerProb1 = ProbLow, - UpperProb1 = ProbUp, - Count1 = Count2, - ResTime1 = ResTime2, - BddTime1 = BddTime2; - - % Keeping on iterating with accumulated values... - % sufficient without negation: - % D1 = DB, - % necessary for negation - bestfirst(Incomplete, Next, Amount, MinError, ProbStep, LowerProb1, UpperProb1, Count2, Count1, ResTime2, ResTime1, BddTime2, BddTime1)). - - - -/* main(GoalsList, Amount, ProbStep, Pending) - * ------------------------------------------------ - * This tail recursive predicate takes the given GoalsList and tries to solve - * the first given Amount quads with the given ProbStep bound on probability, - * one at a time. After each resolution step, it merges the new solutions to the - * current list of solutions so that each time it can consider the most - * promising solution. It finally returns the list of pending solutions, if any. - * - * INPUT - * - GoalsList: current list of goals to solve. - * - Amount: current number of goals to solve. - * - ProbStep: incremental probability step for bound. - * - * OUTPUT - * - Sorted: desired sorted (by non increasing prob) results. - */ -main([], _Amount, _Step, []) :- !. -%% Closing condition: stop if no more goals (pending list is an empty list). - -main(Pending, Amount, _Step, Pending) :- - Amount =< 0, !. - %% Closing condition: stop if reached desired amount (pending list is current list). - -main([Prob0-(Gnd0, Var0, Goals0)|Tail], Amount, Step, Pending) :- - %% Note: Current list is surely not empty. - %% Note: A certain amount is surely still needed. - Bound is Prob0 + Step, - findall(Prob1-(Gnd1, Var1, Goals1), - explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)), - List), - %% Find all the solutions reacheable from the first quad. - sort(List, Sorted), - merge(Tail, Sorted, Complete), - - Needed is Amount - 1, - %% Count current quad as considered. - main(Complete, Needed, Step, Pending). - %% Recursive call: consider next quad (updating pending list). - %% Note: Complete list is sorted; this assures we always consider best quad. - - - -/* merge(SortedA, SortedB, Sorted) - * ------------------------------- - * This tail recursive predicate merges the quads in SortedA and SortedB list by - * non-increasing values of Prob and returns the desired unique Sorted list. - * The SortedA and SortedB lists must be sorted. - * - * INPUT - * - SortedA: first sorted list of quads. - * - SortedB: second sorted list of quads. - * - * OUTPUT - * - Sorted: resulting unique sorted list of quads. - */ -merge(Sorted, [], Sorted) :- !. -%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). - -merge([], Sorted, Sorted). -%% Closing condition: stop if no more items in first sorted list (current second sorted list is output sorted list). - -merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbA-(GndA, VarA, GoalsA)|Tail]) :- - ProbA >= ProbB, !, - merge(TailA, [ProbB-(GndB, VarB, GoalsB)|TailB], Tail). - %% Recursive call: use the first quad (merge the rest of the first list with the second one). - -merge([ProbA-(GndA, VarA, GoalsA)|TailA], [ProbB-(GndB, VarB, GoalsB)|TailB], [ProbB-(GndB, VarB, GoalsB)|Tail]) :- -% ProbA < ProbB, !, - merge([ProbA-(GndA, VarA, GoalsA)|TailA], TailB, Tail). - %% Recursive call: use the second quad (merge the first list with the rest of the second one). - - - -/* separate(List, Low, Up, Next) - * ---------------------------------- - * This tail recursive predicate parses the input list and builds the list for - * the lower bound, the upper bound and the pending goals. - * The upper bound list contains both the items of the lower bound list and the - * incomplete ones. - * - * INPUT - * - List: input list. - * - * OUTPUT - * - Low: list for lower bound. - * - Up: list for upper bound. - * - Next: list of pending goals. - */ -separate(List, Low, Up, Next) :- -%% Polarization: initial low, up and next lists are empty. - separate(List, [], Low, [], Up, [], Next). - -separate([], Low, Low, Up, Up, Next, Next) :- !. -%% Closing condition: stop if no more results (current lists are now final lists). - -separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- - get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), - append(Gnd0, Gnd2, Gnd1), - Prob1 is Prob0 + log(Prob2), - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - - - -/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) - * -------------------------------------------------------------------------- - * This tail recursive predicate reads current explanation and returns the - * explanation after the current iteration without dropping below the given - * probability bound. - * - * INPUT - * - ProbBound: the desired probability bound; - * - Prob0-(Gnd0, Var0, Goals0): current explanation - * - Gnd0: list of current ground choices, - * - Var0: list of current non-ground choices, - * - Prob0: probability of Gnd0, - * - Goals0: list of current goals. - * - * OUTPUT - * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration - * - Gnd1: list of final ground choices, - * - Var1: list of final non-ground choices, - * - Prob1: probability of Gnd1, - * - Goals1: list of final goals. - */ -explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. -%% Closing condition: stop if no more goals (input values are output values). - -explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- - %% Closing condition: stop if bound has been reached (input values are output values). - Prob =< ProbBound, !. - -% Negation, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call((\+ Head)), - explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - %% Recursive call: consider next goal (building next values) - -% Negation -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, - list2and(HeadList, Head), % ... - findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> - separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), - (PendingGoals \= [] -> - Var2 = Var0, - Gnd2 = Gnd0, - Goals1 = [\+ Head|Goals], - explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); - %% Recursive call: consider next goal (building next values) - - choose_clausesc(Gnd0, Var0, LowerBound, Var), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). - %% Recursive call: consider next goal (building next values) - -% Main, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call(Head), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, def_rule -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - def_rule(Head, Goals0), - append(Goals0, Tail, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, find_rulec -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - find_rulec(Head, (R, S, N), Goals, Var0, _Prob), - explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- - (member_eq((N, R, S), Var0); - member_eq((N, R, S), Gnd0)), !, - append(Goals, Goals0, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). - % Recursive call: consider next goal (building next values) - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- - append(Var0, [(N, R, S)], Var), - append(Goals, Goals0, Goals2), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - - - -/* eval_lower(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the lower bound by - * running an external command (BDD resolution via files). - */ -eval_lower(Number, Prob) :- - low(Number, Prob). - -eval_lower(Number, ProbLow) :- - Number > 0, - low(OldNumber, _), - Number \= OldNumber, - bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), - run_file('bddl.txt', 'bddl.par', NewProbLow), - (NewProbLow = timeout -> - low(_, ProbLow); - - ProbLow = NewProbLow, - retract(low(_, _)), - assert(low(Number, ProbLow))). - - - -/* eval_upper(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the upper bound by - * running an external command (BDD resolution via files). - */ -eval_upper(0, ProbUp) :- !, - low(_, ProbUp). - -eval_upper(_Number, ProbUp) :- - bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), - run_file('bddu.txt', 'bddu.par', NewProbUp), - (NewProbUp = timeout-> - up(ProbUp); - ProbUp = NewProbUp, - retract(up(_)), - assert(up(ProbUp))). - - - -/* run_file(BDDFile, BDDParFile, Prob) - * ----------------------------------- - * This predicate calls for the resolution of a BDD via file. - */ -run_file(BDDFile, BDDParFile, Prob) :- - ResultFile = 'result.txt', - library_directory(Dir), - setting(timeout, BDDTime), - (BDDTime = no -> - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), - - %statistics(walltime,_), - - shell(Command, Return), - (Return =\= 0 -> - Status = timeout, - Prob = Status; - - see(ResultFile), - read(elapsed_construction(_TimeConstruction)), - read(probability(Prob)), - read(elapsed_traversing(_TimeTraversing)), - seen, - - %write(probability(Prob)),nl, - %read(_), - %delete_file(ResultFile), - - Status = ok - % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) - ). - - %statistics(walltime,[_,E3]), - %format(user,'~w ms BDD processing~Number',[E3]), - % format("Status ~a~Number",[Status]). - - - -/* insert_list_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the given list in a trie. - */ -insert_list_ptree([], _Trie). - -insert_list_ptree([Head|Tail], Trie) :- - reverse(Head, Head1), - insert_ptree(Head1, Trie), - insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base b/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base deleted file mode 100644 index 7a47c8fd5..000000000 --- a/packages/cplint/approx/.svn/text-base/bestk.pl.svn-base +++ /dev/null @@ -1,528 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File best.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(system)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(tptreefile). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(Goals, Prob, ResTime, BddTime) - * ------------------------------------ - * This predicate computes the probability of a given list of goals using an - * iterative deepening, probability bounded algorithm. - * It also returns the number of handled BDDs and the CPUTime spent performing - * resolution and spent handling the BDDs. - * - * Note: when their derivation is cut, negative goals are added to the head of - * the goals' list to be solved during the following iteration. - * - * INPUT - * - GoalsList: given list of goal to work on. It can contains variables: the - * predicate returns in backtracking all the solutions and their equivalent - * lower and upper bound probability. - * - * OUTPUT - * - Prob: resulting lower bound probability for the given list of goals. - * - ResTime: CPU time spent on performing resolution. - * - BddTime: CPU time spent on handling BDDs. - */ -solve(Goals, Prob, ResTime, BddTime) :- - setting(k, K), - setting(prob_step, ProbStep), - ProbStepLog is log(ProbStep), - % NB: log(1.0) == 0.0 !!! - bestk([0.0-0.0-([], [], Goals)], K, ProbStepLog, Prob, ResTime, BddTime). - - - -/* bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) - * ----------------------------------------------------- - * This recursive supporting predicate performs resolution for current iteration, - * sticks with the best complete solutions only and considers their equivalent - * BDD to compute their probability. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - K: number of solution to consider. - * - ProbStep: value used to update the probability bound. - * - * OUTPUT - * - Prob: resulting probability (actaully a lower bound) for the given list of goals. - * - ResTime: cpu time spent on performing resolution. - * - BddTime: cpu time spent on handling BDDs. - */ -bestk(GoalsList, K, ProbStep, Prob, ResTime, BddTime) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - - % Performing resolution... - main(GoalsList, K, ProbStep, BestK), - - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime is ElapResTime/1000, - - % Building and solving equivalent bdds... - init_ptree(1), - insert_full_ptree(BestK, 1), - bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), - delete_ptree(1), - run_file('bdd.txt','bdd.par', Temp), - (Temp == timeout -> - Prob is -1.0; - Prob is Temp), - - % Taking elapsed times... - statistics(walltime, [_, ElapBddTime]), - BddTime is (ElapBddTime / 1000). - - - -/* main(Goals, K, ProbStep, Best) - * ------------------------------ - * This tail recursive predicate returns the Best K complete solutions to the - * given Goals. The probability bound is dinamically computed at each iteration. - * - * INPUT - * - Goals: list of goals to achive. - * - K: desired number of solutions. - * - ProbStep: value used to update the probability bound. - * - * OUTPUT - * - Best: list of best solutions (at most k). - */ -main(Goals, K, ProbStep, Best) :- - K > 0, - main(Goals, ProbStep, K, 0.0, [], Best). - -main([], _ProbStep, _Left, _Worst, Best, Best). - -main(Goals, ProbStep, Left0, Worst0, Best0, Best1) :- - findall(Prob1-Bound-(Gnd1, Var1, Goals1), - (member(Prob0-Bound0-(Gnd0, Var0, Goals0), Goals), Bound is Bound0+ ProbStep, explore(Bound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), - Found), - %% sepkeepbest(Found, Left0, Left2, Worst0, Worst2, Best0, Best2, [], Incomplete), - separate_main(Found, [], Complete, [], _UpperList, [], Incomplete), - keepbest(Complete, Left0, Left2, Worst0, Worst2, Best0, Best2), - main(Incomplete, ProbStep, Left2, Worst2, Best2, Best1). - - - -/* sepkeepbest(Found, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) - * ---------------------------------------------------------------------------- - * This tail recursive predicate analyzes the given list of solutions found and - * returns the list of (K at most) best complete solutions and the whole list of - * incomplete solutions for a full B&B behaviour. - * The given worst value permits some optimization, such as immediate skipping - * of very bad solutions. - * - * INPUT - * - Found: list of solutions found. - * - Left0: actual amount of items still needed to have K solutions. - * - Worst0: value of the actual worst complete solution kept. - * - List0: actual list of best complete solutions. - * - Next0: actual list of incomplete solutions. - * - * OUTPUT - * - Left1: final amount of items still needed to have K solutions. - * - Worst1: value of the final worst complete solution kept. - * - List1: final list of best complete solutions. - * - Next1: final list of incomplete solutions. - */ -sepkeepbest([], Left, Left, Worst, Worst, List, List, Next, Next) :- !. -%% Closing condition: stop if no more results (current values are now final values). - -sepkeepbest([Prob0-(_Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- - Prob0 =< Worst0, !, - sepkeepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). - -sepkeepbest([Prob0-(Gnd0, [], [])|Tail], 0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- - Prob0 > Worst0, !, - discard(Prob0-(Gnd0, [], []), List0, List2, Worst2), - sepkeepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1, Next0, Next1). - -sepkeepbest([Prob0-(Gnd0, [], [])|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1) :- !, - insert(Prob0-(Gnd0, [], []), List0, Worst0, List2, Worst2), - Left2 is Left0 - 1, - sepkeepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1, Next0, Next1). - -sepkeepbest([Prob0-(Gnd0, Var0, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1, Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- - get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), - append(Gnd0, Gnd2, Gnd1), - Prob1 is Prob0 + log(Prob2), - sepkeepbest(Tail, Left0, Left1, Worst0, Worst1, List0, List1, Next0, Next1). - - - -/* separate(List, Low, Up, Next) - * ----------------------------- - * This tail recursive predicate parses the input list and builds the list for - * the lower bound, the upper bound and the pending goals. - * The upper bound list contains both the items of the lower bound list and the - * incomplete ones. - * - * INPUT - * - List: input list. - * - * OUTPUT - * - Low: list for lower bound. - * - Up: list for upper bound. - * - Next: list of pending goals. - */ -separate(List, Low, Up, Next) :- -%% Polarization: initial low, up and next lists are empty. - separate(List, [], Low, [], Up, [], Next). - -separate([], Low, Low, Up, Up, Next, Next) :- !. -%% Closing condition: stop if no more results (current lists are now final lists). - -separate([Prob0-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-(Gnd0, Var0, Goals)|Next1]) :- - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate_main([], Low, Low, Up, Up, Next, Next) :- !. -%% Closing condition: stop if no more results (current lists are now final lists). - -separate_main([Prob0-_Bound0-(Gnd0, [], [])|Tail], Low0, [Prob0-(Gnd0, [], [])|Low1], Up0, [Prob0-(Gnd0, [], [])|Up1], Next0, Next1) :- !, - separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate_main([Prob0-Bound0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Up1], Next0, [Prob0-Bound0-(Gnd0, Var0, Goals)|Next1]) :- - separate_main(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - - - -/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) - * -------------------------------------------------------------------------- - * This tail recursive predicate reads current explanation and returns the - * explanation after the current iteration without dropping below the given - * probability bound. - * - * INPUT - * - ProbBound: the desired probability bound; - * - Prob0-(Gnd0, Var0, Goals0): current explanation - * - Gnd0: list of current ground choices, - * - Var0: list of current non-ground choices, - * - Prob0: probability of Gnd0, - * - Goals0: list of current goals. - * - * OUTPUT - * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration - * - Gnd1: list of final ground choices, - * - Var1: list of final non-ground choices, - * - Prob1: probability of Gnd1, - * - Goals1: list of final goals. - */ -explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. -%% Closing condition: stop if no more goals (input values are output values). - -explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- - %% Closing condition: stop if bound has been reached (input values are output values). - Prob =< ProbBound, !. - -% Negation, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call((\+ Head)), - explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - %% Recursive call: consider next goal (building next values) - -% Negation -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, - list2and(HeadList, Head), % ... - findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> - separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), - (PendingGoals \= [] -> - Var2 = Var0, - Gnd2 = Gnd0, - Goals1 = [\+ Head|Goals], - explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); - %% Recursive call: consider next goal (building next values) - - choose_clausesc(Gnd0, Var0, LowerBound, Var), - get_prob(Var, 1, Prob), - append(Gnd0, Var, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, [], Tail), Prob1-(Gnd1, Var1, Goals1))). - %% Recursive call: consider next goal (building next values) - -% Main, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call(Head), - explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, def_rule -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - def_rule(Head, Goals0), - append(Goals0, Tail, Goals2), - explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, find_rulec -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - find_rulec(Head, (R, S, N), Goals, Var0, _Prob), - explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- - (member_eq((N, R, S), Var0); - member_eq((N, R, S), Gnd0)), !, - append(Goals, Goals0, Goals2), - explore(ProbBound, Prob0-(Gnd0, Var0, Goals2), Prob1-(Gnd1, Var1, Goals)). - % Recursive call: consider next goal (building next values) - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- - append(Var0, [(N, R, S)], Var), - append(Goals, Goals0, Goals2), - get_prob(Var, 1, Prob), - append(Gnd0, Var, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, [], Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - - - -/* keepbest(List, K, BestK) - * ------------------------ - * This tail recursive predicate parses the given list of quads and returns the - * list of its best k quads. If the given list of quads contains less than k - * items, the predicate returns them all. - * - * INPUT - * - List: list of quads to parse. - * - K: desired number of quads. - * - * OUTPUT - * - BestK: final list of (at most) best k quads. - */ -keepbest(List, K, BestK) :- - K > 0, - keepbest(List, K, _Left, 0.0, _Worst, [], BestK). - -/*keepbest([], _Left, _Worst, List, List). - -keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Worst, List0, List1) :- - Prob =< Worst, !, - keepbest(Tail, 0, Worst, List0, List1). - -keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Worst, List0, List1) :- - Prob > Worst, !, - discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), - keepbest(Tail, 0, Worst2, List2, List1). - -keepbest([Prob-(Gnd, Var, Goals)|Tail], Left, Worst, List0, List1) :- - insert(Prob-(Gnd, Var, Goals), List0, Worst, List2, Worst2), - Left2 is Left - 1, - keepbest(Tail, Left2, Worst2, List2, List1).*/ - - - -keepbest([], Left, Left, Worst, Worst, List, List). - -keepbest([Prob-(_Gnd, _Var, _Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- - Prob =< Worst0, !, - keepbest(Tail, 0, Left1, Worst0, Worst1, List0, List1). - -keepbest([Prob-(Gnd, Var, Goals)|Tail], 0, Left1, Worst0, Worst1, List0, List1) :- - Prob > Worst0, !, - discard(Prob-(Gnd, Var, Goals), List0, List2, Worst2), - keepbest(Tail, 0, Left1, Worst2, Worst1, List2, List1). - -keepbest([Prob-(Gnd, Var, Goals)|Tail], Left0, Left1, Worst0, Worst1, List0, List1) :- - insert(Prob-(Gnd, Var, Goals), List0, Worst0, List2, Worst2), - Left2 is Left0 - 1, - keepbest(Tail, Left2, Left1, Worst2, Worst1, List2, List1). - - - -/* insert(Prob-(Gnd, Var, Goals), Sorted0, Worst0, Sorted1, Worst1) - * ---------------------------------------------------------------- - * This tail recursive predicate inserts the given quad into the given sorted - * list and returns the final sorted list. The input list must be sorted. - * It also updates the prob value of the worst quad. - * - * INPUT - * - Prob-(Gnd, Var, Goals): quad to insert. - * - Sorted0: sorted list to insert the quad into. - * - Worst0: current worst prob value. - * - * OUTPUT - * - Sorted1: the final sorted list. - * - Worst1: the final worst prob value. - */ -insert(Prob-(Gnd, Var, Goals), [], _Worst, [Prob-(Gnd, Var, Goals)], Prob). - -insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst, [Prob-(Gnd, Var, Goals), Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst) :- - Prob >= Prob_i, !. - -insert(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i)|Tail], Worst0, [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst1) :- - Prob < Prob_i, !, - insert(Prob-(Gnd, Var, Goals), Tail, Worst0, Next, Worst1). - - - -/* discard(Prob-(Gnd, Var, Goals), Sorted0, Sorted1, Worst) - * -------------------------------------------------------- - * This tail recursive predicate inserts the given quad into the given sorted - * list, removes the last quad from it and returns the final sorted list. - * The given sorted list contains at least one quad and must be sorted. - * Previous worst prob value is not needed because it necessarely changes and - * the new value is not known in advance. - * It also updates the prob value of the worst quad. - * - * INPUT - * - Prob-(Gnd, Var, Goals): quad to insert. - * - Sorted0: sorted list to insert the quad into. - * - * OUTPUT - * - Sorted1: the final sorted list. - * - Worst: the final worst prob value. - */ -discard(Prob-(Gnd, Var, Goals), [_Prob_i-(_Gnd_i, _Var_i, _Goals_i)], [Prob-(Gnd, Var, Goals)], Prob) :- !. - -discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob-(Gnd, Var, Goals)|Next], Worst) :- - Prob >= Prob_i, !, - discard(Prob_i-(Gnd_i, Var_i, Goals_i), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). - -discard(Prob-(Gnd, Var, Goals), [Prob_i-(Gnd_i, Var_i, Goals_i), Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], [Prob_i-(Gnd_i, Var_i, Goals_i)|Next], Worst) :- - Prob < Prob_i, !, - discard(Prob-(Gnd, Var, Goals), [Prob_l-(Gnd_l, Var_l, Goals_l)|Tail], Next, Worst). - - - -/* eval_lower(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the lower bound by - * running an external command (BDD resolution via files). - */ -eval_lower(Number, Prob) :- - low(Number, Prob). - -eval_lower(Number, ProbLow) :- - Number > 0, - low(OldNumber, _), - Number \= OldNumber, - bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), - run_file('bddl.txt', 'bddl.par', NewProbLow), - (NewProbLow = timeout -> - low(_, ProbLow); - - ProbLow = NewProbLow, - retract(low(_, _)), - assert(low(Number, ProbLow))). - - - -/* eval_upper(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the upper bound by - * running an external command (BDD resolution via files). - */ -eval_upper(0, ProbUp) :- !, - low(_, ProbUp). - -eval_upper(_Number, ProbUp) :- - bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), - run_file('bddu.txt', 'bddu.par', NewProbUp), - (NewProbUp = timeout-> - up(ProbUp); - ProbUp = NewProbUp, - retract(up(_)), - assert(up(ProbUp))). - - - -/* run_file(BDDFile, BDDParFile, Prob) - * ----------------------------------- - * This predicate calls for the resolution of a BDD via file. - */ -run_file(BDDFile, BDDParFile, Prob) :- - ResultFile = 'result.txt', - library_directory(Dir), - setting(timeout, BDDTime), - (BDDTime = no -> - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), - - %statistics(walltime,_), - - shell(Command, Return), - (Return =\= 0 -> - Status = timeout, - Prob = Status; - - see(ResultFile), - read(elapsed_construction(_TimeConstruction)), - read(probability(Prob)), - read(elapsed_traversing(_TimeTraversing)), - seen, - - %write(probability(Prob)),nl, - %read(_), - %delete_file(ResultFile), - - Status = ok - % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) - ). - - %statistics(walltime,[_,E3]), - %format(user,'~w ms BDD processing~Number',[E3]), - % format("Status ~a~Number",[Status]). - - - -/* insert_full_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the ground part of the given list in a trie. - */ -insert_full_ptree([], _Trie). - -insert_full_ptree([_Prob-(Gnd, _Var, _Goals)|Tail], Trie) :- - reverse(Gnd, Gnd1), - insert_ptree(Gnd1, Trie), - insert_full_ptree(Tail, Trie). - - - -/* insert_list_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the given list in a trie. - */ -insert_list_ptree([], _Trie). - -insert_list_ptree([Head|Tail], Trie) :- - reverse(Head, Head1), - insert_ptree(Head1, Trie), - insert_list_ptree(Tail, Trie). - - diff --git a/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base b/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base deleted file mode 100644 index 8bdb8b981..000000000 --- a/packages/cplint/approx/.svn/text-base/deepdyn.pl.svn-base +++ /dev/null @@ -1,352 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File deepit.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(system)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(tptreefile). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) - * --------------------------------------------------- - * This predicate computes the probability of a given list of goals using an - * iterative deepening algorithm. It also returns the number of handled BDDs and - * CPUTime spent in performing resolution and in handling the BDDs. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - * OUTPUT - * - ProbLow: the resulting lowerbound probability for the given list of goals. - * - ProbUp: the resulting upperbound probability for the given list of goals. - * - ResTime: cpu time spent on performing resolution. - * - BddTime: cpu time spent on handling BDDs. - */ -solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- - setting(min_error, MinError), - setting(prob_step, ProbStep), - - LogProbStep is log(ProbStep), - - assert(low(0,0.0)), - assert(up(1.0)), - init_ptree(1), - - % NB: log(1.0) == 0.0 !!! - deepdyn([0.0-([], [], GoalsList)], 0, MinError, LogProbStep, ProbLow, ProbUp, 0, ResTime, 0, BddTime), - - delete_ptree(1), - retract(low(_,_)), - retract(up(_)). - - - -/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where -CG is the list of ground choices, C is the list of non-ground choices, -P is the probability of CG, G is the list of goals to be resolved, -Succ is the list of explanations found so far, PB is the current prob bound, -ProbL0,ProbU0 are the lower/upper prob bounds */ - -deepdyn(GoalsList, Number, MinError, ProbStep, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - - % Performing resolution... - findall(Prob1-(Gnd1, Var1, Goals1), - (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), ProbBound is log(Prob0) + ProbStep, explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), - List), - - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime2 is ResTime0 + ElapResTime/1000, - - % Building and solving equivalent bdds... - init_ptree(2), - init_ptree(3), - separate(List, [], LowerList0, [], UpperList, [], Incomplete), - insert_list_ptree(LowerList0, 1), - insert_list_ptree(UpperList, 2), - merge_ptree(1,2,3), - - length(LowerList0, DeltaLow), - Next is Number + DeltaLow, - eval_lower(Next, ProbLow), - - length(UpperList, DeltaUp), - Temp is Next + DeltaUp, - eval_upper(Temp, ProbUp), - - delete_ptree(2), - delete_ptree(3), - - % Taking elapsed times... - statistics(walltime, [_, ElapBddTime]), - BddTime2 is BddTime0 + (ElapBddTime / 1000), - - % Is the current error lower than the minimum error? - (ProbUp - ProbLow < MinError -> - % Setting output parameters' values... - LowerProb1 = ProbLow, - UpperProb1 = ProbUp, - ResTime1 = ResTime2, - BddTime1 = BddTime2; - - % Keeping on iterating with accumulated values... - % sufficient without negation: - % D1 = DB, - % necessary for negation - deepdyn(Incomplete, Next, MinError, ProbStep, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). - - - -/* separate(List, Low, Up, Next) - * ---------------------------------- - * This tail recursive predicate parses the input list and builds the list for - * the lower bound, the upper bound and the pending goals. - * The upper bound list contains both the items of the lower bound list and the - * incomplete ones. - * - * INPUT - * - List: input list. - * - * OUTPUT - * - Low: list for lower bound. - * - Up: list for upper bound. - * - Next: list of pending goals. - */ -separate(List, Low, Up, Next) :- -%% Polarization: initial low, up and next lists are empty. - separate(List, [], Low, [], Up, [], Next). - -separate([], Low, Low, Up, Up, Next, Next) :- !. -%% Closing condition: stop if no more results (current lists are now final lists). - -separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- - get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), - append(Gnd0, Gnd2, Gnd1), - Prob1 is Prob0 + log(Prob2), - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - - - -/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) - * -------------------------------------------------------------------------- - * This tail recursive predicate reads current explanation and returns the - * explanation after the current iteration without dropping below the given - * probability bound. - * - * INPUT - * - ProbBound: the desired probability bound; - * - Prob0-(Gnd0, Var0, Goals0): current explanation - * - Gnd0: list of current ground choices, - * - Var0: list of current non-ground choices, - * - Prob0: probability of Gnd0, - * - Goals0: list of current goals. - * - * OUTPUT - * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration - * - Gnd1: list of final ground choices, - * - Var1: list of final non-ground choices, - * - Prob1: probability of Gnd1, - * - Goals1: list of final goals. - */ -explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. -%% Closing condition: stop if no more goals (input values are output values). - -explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- - %% Closing condition: stop if bound has been reached (input values are output values). - Prob =< ProbBound, !. - -% Negation, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call((\+ Head)), - explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - %% Recursive call: consider next goal (building next values) - -% Negation -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, - list2and(HeadList, Head), % ... - findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> - separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), - (PendingGoals \= [] -> - Var2 = Var0, - Gnd2 = Gnd0, - Goals1 = [\+ Head|Goals], - explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); - %% Recursive call: consider next goal (building next values) - - choose_clausesc(Gnd0, Var0, LowerBound, Var), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). - %% Recursive call: consider next goal (building next values) - -% Main, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call(Head), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, def_rule -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - def_rule(Head, Goals0), - append(Goals0, Tail, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, find_rulec -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - find_rulec(Head, (R, S, N), Goals, Var0, _Prob), - explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- - (member_eq((N, R, S), Var0); - member_eq((N, R, S), Gnd0)), !, - append(Goals, Goals0, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). - % Recursive call: consider next goal (building next values) - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- - append(Var0, [(N, R, S)], Var), - append(Goals, Goals0, Goals2), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - - - -/* eval_lower(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the lower bound by - * running an external command (BDD resolution via files). - */ -eval_lower(Number, Prob) :- - low(Number, Prob). - -eval_lower(Number, ProbLow) :- - Number > 0, - low(OldNumber, _), - Number \= OldNumber, - bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), - run_file('bddl.txt', 'bddl.par', NewProbLow), - (NewProbLow = timeout -> - low(_, ProbLow); - - ProbLow = NewProbLow, - retract(low(_, _)), - assert(low(Number, ProbLow))). - - - -/* eval_upper(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the upper bound by - * running an external command (BDD resolution via files). - */ -eval_upper(0, ProbUp) :- !, - low(_, ProbUp). - -eval_upper(_Number, ProbUp) :- - bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), - run_file('bddu.txt', 'bddu.par', NewProbUp), - (NewProbUp = timeout-> - up(ProbUp); - ProbUp = NewProbUp, - retract(up(_)), - assert(up(ProbUp))). - - - -/* run_file(BDDFile, BDDParFile, Prob) - * ----------------------------------- - * This predicate calls for the resolution of a BDD via file. - */ -run_file(BDDFile, BDDParFile, Prob) :- - ResultFile = 'result.txt', - library_directory(Dir), - setting(timeout, BDDTime), - (BDDTime = no -> - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), - - %statistics(walltime,_), - - shell(Command, Return), - (Return =\= 0 -> - Status = timeout, - Prob = Status; - - see(ResultFile), - read(elapsed_construction(_TimeConstruction)), - read(probability(Prob)), - read(elapsed_traversing(_TimeTraversing)), - seen, - - %write(probability(Prob)),nl, - %read(_), - %delete_file(ResultFile), - - Status = ok - % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) - ). - - %statistics(walltime,[_,E3]), - %format(user,'~w ms BDD processing~Number',[E3]), - % format("Status ~a~Number",[Status]). - - - -/* insert_list_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the given list in a trie. - */ -insert_list_ptree([], _Trie). - -insert_list_ptree([Head|Tail], Trie) :- - reverse(Head, Head1), - insert_ptree(Head1, Trie), - insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base b/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base deleted file mode 100644 index 52c71047c..000000000 --- a/packages/cplint/approx/.svn/text-base/deepit.pl.svn-base +++ /dev/null @@ -1,352 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File deepit.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(system)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(tptreefile). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(GoalsList, ProbLow, ProbUp, ResTime, BddTime) - * --------------------------------------------------- - * This predicate computes the probability of a given list of goals using an - * iterative deepening algorithm. It also returns the number of handled BDDs and - * CPUTime spent in performing resolution and in handling the BDDs. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - * OUTPUT - * - ProbLow: the resulting lowerbound probability for the given list of goals. - * - ProbUp: the resulting upperbound probability for the given list of goals. - * - ResTime: cpu time spent on performing resolution. - * - BddTime: cpu time spent on handling BDDs. - */ -solve(GoalsList, ProbLow,ProbUp, ResTime, BddTime):- - setting(min_error, MinError), - setting(prob_bound, ProbBound), - - LogProbBound is log(ProbBound), - - assert(low(0,0.0)), - assert(up(1.0)), - init_ptree(1), - - % NB: log(1.0) == 0.0 !!! - deepit([0.0-([], [], GoalsList)], 0, MinError, LogProbBound, ProbLow, ProbUp, 0, ResTime, 0, BddTime), - - delete_ptree(1), - retract(low(_,_)), - retract(up(_)). - - - -/* solve_t(L0,Succ,PB,ProbL0,ProbU0) L0 is a list of quadruples (CG,C,P,G) where -CG is the list of ground choices, C is the list of non-ground choices, -P is the probability of CG, G is the list of goals to be resolved, -Succ is the list of explanations found so far, PB is the current prob bound, -ProbL0,ProbU0 are the lower/upper prob bounds */ - -deepit(GoalsList, Number, MinError, ProbBound, LowerProb1, UpperProb1, ResTime0, ResTime1, BddTime0, BddTime1) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - - % Performing resolution... - findall(Prob1-(Gnd1, Var1, Goals1), - (member(Prob0-(Gnd0, Var0, Goals0), GoalsList), explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1))), - List), - - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime2 is ResTime0 + ElapResTime/1000, - - % Building and solving equivalent bdds... - init_ptree(2), - init_ptree(3), - separate(List, [], LowerList0, [], UpperList, [], Incomplete), - insert_list_ptree(LowerList0, 1), - insert_list_ptree(UpperList, 2), - merge_ptree(1,2,3), - - length(LowerList0, DeltaLow), - Next is Number + DeltaLow, - eval_lower(Next, ProbLow), - - length(UpperList, DeltaUp), - Temp is Next + DeltaUp, - eval_upper(Temp, ProbUp), - - delete_ptree(2), - delete_ptree(3), - - % Taking elapsed times... - statistics(walltime, [_, ElapBddTime]), - BddTime2 is BddTime0 + (ElapBddTime / 1000), - - % Is the current error lower than the minimum error? - (ProbUp - ProbLow < MinError -> - % Setting output parameters' values... - LowerProb1 = ProbLow, - UpperProb1 = ProbUp, - ResTime1 = ResTime2, - BddTime1 = BddTime2; - - % Keeping on iterating with accumulated values... - % sufficient without negation: - % D1 = DB, - % necessary for negation - deepit(Incomplete, Next, MinError, ProbBound, LowerProb1, UpperProb1, ResTime2, ResTime1, BddTime2, BddTime1)). - - - -/* separate(List, Low, Up, Next) - * ---------------------------------- - * This tail recursive predicate parses the input list and builds the list for - * the lower bound, the upper bound and the pending goals. - * The upper bound list contains both the items of the lower bound list and the - * incomplete ones. - * - * INPUT - * - List: input list. - * - * OUTPUT - * - Low: list for lower bound. - * - Up: list for upper bound. - * - Next: list of pending goals. - */ -separate(List, Low, Up, Next) :- -%% Polarization: initial low, up and next lists are empty. - separate(List, [], Low, [], Up, [], Next). - -separate([], Low, Low, Up, Up, Next, Next) :- !. -%% Closing condition: stop if no more results (current lists are now final lists). - -separate([_Prob-(Gnd0, [], [])|Tail], Low0, [Gnd0|Low1], Up0, [Gnd0|Up1], Next0, Next1) :- !, - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - -separate([Prob0-(Gnd0, Var0, Goals)|Tail], Low0, Low1, Up0, [Gnd1|Up1], Next0, [Prob1-(Gnd1, Var1, Goals)|Next1]) :- - get_groundc(Var0, Gnd2, Var1, 1.0, Prob2), - append(Gnd0, Gnd2, Gnd1), - Prob1 is Prob0 + log(Prob2), - separate(Tail, Low0, Low1, Up0, Up1, Next0, Next1). - - - -/* explore(ProbBound, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) - * -------------------------------------------------------------------------- - * This tail recursive predicate reads current explanation and returns the - * explanation after the current iteration without dropping below the given - * probability bound. - * - * INPUT - * - ProbBound: the desired probability bound; - * - Prob0-(Gnd0, Var0, Goals0): current explanation - * - Gnd0: list of current ground choices, - * - Var0: list of current non-ground choices, - * - Prob0: probability of Gnd0, - * - Goals0: list of current goals. - * - * OUTPUT - * - Prob1-(Gnd1, Var1, Prob1, Goals1): explanation after current iteration - * - Gnd1: list of final ground choices, - * - Var1: list of final non-ground choices, - * - Prob1: probability of Gnd1, - * - Goals1: list of final goals. - */ -explore(_ProbBound, Prob-(Gnd, Var, []), Prob-(Gnd, Var, [])) :- !. -%% Closing condition: stop if no more goals (input values are output values). - -explore(ProbBound, Prob-(Gnd, Var, Goals), Prob-(Gnd, Var, Goals)) :- - %% Closing condition: stop if bound has been reached (input values are output values). - Prob =< ProbBound, !. - -% Negation, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call((\+ Head)), - explore(ProbBound, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - %% Recursive call: consider next goal (building next values) - -% Negation -explore(ProbBound, Prob0-(Gnd0, Var0, [\+ Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- !, - list2and(HeadList, Head), % ... - findall(Prob-(Gnd, Var, CurrentGoals), explore(ProbBound, 0.0-([], [], HeadList), Prob-(Gnd, Var, CurrentGoals)), List) -> - separate(List, [], LowerBound, [], _UpperBound, [], PendingGoals), - (PendingGoals \= [] -> - Var2 = Var0, - Gnd2 = Gnd0, - Goals1 = [\+ Head|Goals], - explore(ProbBound, Prob0-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals)); - %% Recursive call: consider next goal (building next values) - - choose_clausesc(Gnd0, Var0, LowerBound, Var), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1))). - %% Recursive call: consider next goal (building next values) - -% Main, builtin -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - builtin(Head), !, - call(Head), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Tail), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, def_rule -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - def_rule(Head, Goals0), - append(Goals0, Tail, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - -% Main, find_rulec -explore(ProbBound, Prob0-(Gnd0, Var0, [Head|Tail]), Prob1-(Gnd1, Var1, Goals1)) :- - find_rulec(Head, (R, S, N), Goals, Var0, _Prob), - explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Tail), Prob1-(Gnd1, Var1, Goals1)). - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals)) :- - (member_eq((N, R, S), Var0); - member_eq((N, R, S), Gnd0)), !, - append(Goals, Goals0, Goals2), - get_groundc(Var0, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals)). - % Recursive call: consider next goal (building next values) - -explore_pres(ProbBound, R, S, N, Goals, Prob0-(Gnd0, Var0, Goals0), Prob1-(Gnd1, Var1, Goals1)) :- - append(Var0, [(N, R, S)], Var), - append(Goals, Goals0, Goals2), - get_groundc(Var, Gnd, Var2, 1, Prob), - append(Gnd0, Gnd, Gnd2), - Prob2 is Prob0 + log(Prob), - explore(ProbBound, Prob2-(Gnd2, Var2, Goals2), Prob1-(Gnd1, Var1, Goals1)). - % Recursive call: consider next goal (building next values) - - - -/* eval_lower(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the lower bound by - * running an external command (BDD resolution via files). - */ -eval_lower(Number, Prob) :- - low(Number, Prob). - -eval_lower(Number, ProbLow) :- - Number > 0, - low(OldNumber, _), - Number \= OldNumber, - bdd_ptree_map(1, 'bddl.txt', 'bddl.par', 'bddl.map'), - run_file('bddl.txt', 'bddl.par', NewProbLow), - (NewProbLow = timeout -> - low(_, ProbLow); - - ProbLow = NewProbLow, - retract(low(_, _)), - assert(low(Number, ProbLow))). - - - -/* eval_upper(Number, Prob) - * ------------------------ - * This predicate evaluates if there are proofs for the upper bound by - * running an external command (BDD resolution via files). - */ -eval_upper(0, ProbUp) :- !, - low(_, ProbUp). - -eval_upper(_Number, ProbUp) :- - bdd_ptree_map(3, 'bddu.txt', 'bddu.par', 'bddu.map'), - run_file('bddu.txt', 'bddu.par', NewProbUp), - (NewProbUp = timeout-> - up(ProbUp); - ProbUp = NewProbUp, - retract(up(_)), - assert(up(ProbUp))). - - - -/* run_file(BDDFile, BDDParFile, Prob) - * ----------------------------------- - * This predicate calls for the resolution of a BDD via file. - */ -run_file(BDDFile, BDDParFile, Prob) :- - ResultFile = 'result.txt', - library_directory(Dir), - setting(timeout, BDDTime), - (BDDTime = no -> - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), - - %statistics(walltime,_), - - shell(Command, Return), - (Return =\= 0 -> - Status = timeout, - Prob = Status; - - see(ResultFile), - read(elapsed_construction(_TimeConstruction)), - read(probability(Prob)), - read(elapsed_traversing(_TimeTraversing)), - seen, - - %write(probability(Prob)),nl, - %read(_), - %delete_file(ResultFile), - - Status = ok - % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) - ). - - %statistics(walltime,[_,E3]), - %format(user,'~w ms BDD processing~Number',[E3]), - % format("Status ~a~Number",[Status]). - - - -/* insert_list_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the given list in a trie. - */ -insert_list_ptree([], _Trie). - -insert_list_ptree([Head|Tail], Trie) :- - reverse(Head, Head1), - insert_ptree(Head1, Trie), - insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/exact.pl.svn-base b/packages/cplint/approx/.svn/text-base/exact.pl.svn-base deleted file mode 100644 index ead21b34c..000000000 --- a/packages/cplint/approx/.svn/text-base/exact.pl.svn-base +++ /dev/null @@ -1,235 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File best.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(system)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(tptreefile). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(GoalsList, Prob, ResTime, BddTime) - * ---------------------------------------- - * This predicate computes the probability of a given list of goals using an - * exact algorithm. It also returns the number of handled BDDs (trivial but - * present for simmetry with other solving predicates), CPUTime spent in - * performing resolution and in handling the BDDs. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - * OUTPUT - * - Prob: the resulting exact probability for the given list of goals. - * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). - * - ResTime: cpu time spent on performing resolution. - * - BddTime: cpu time spent on handling BDDs. - */ -solve(GoalsList, Prob, ResTime, BddTime) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - - % Performing resolution... - findall(Deriv, exact(GoalsList, Deriv), List), - - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime is ElapResTime/1000, - - % Building and solving equivalent bdds... - init_ptree(1), - fatto(List), - insert_list_ptree(List, 1), - bdd_ptree_map(1, 'bdd.txt', 'bdd.par', 'bdd.map'), - delete_ptree(1), - run_file('bdd.txt','bdd.par', Temp), - (Temp == timeout -> - Prob is -1.0; - Prob is Temp), - - % Taking elapsed times - statistics(walltime, [_, ElapBddTime]), - BddTime is ElapBddTime/1000. - - - -/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set -and returns an output C set -The C set is a list of triple (N, R, S) where -- N is the index of the head atom used, starting from 0 -- R is the index of the non ground rule used, starting from 1 -- S is the substitution of rule R, in the form of a list whose elements - are of the form 'VarName'=value -*/ -exact(GoalsList, Deriv) :- - exact(GoalsList, [], Deriv). - -exact([], C, C) :- !. - -exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, - list2and(GL, G), - bagof((V, C), EV^exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L, [], C1), - remove_duplicates_eq(C1, C2), - exact(T, C2, COut). - -exact([bagof(V, G, L)|T], CIn, COut) :- !, - list2and(GL, G), - bagof((V, C), exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L, [], C1), - remove_duplicates_eq(C1, C2), - exact(T, C2, COut). - -exact([setof(V, EV^G, L)|T], CIn, COut) :- !, - list2and(GL, G), - setof((V, C), EV^exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L1, [], C1), - remove_duplicates(L1, L), - exact(T, C1, COut). - -exact([setof(V, G, L)|T], CIn, COut) :- !, - list2and(GL, G), - setof((V, C), exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L1, [], C1), - remove_duplicates(L1, L), - exact(T, C1, COut). - -exact([\+ H|T], CIn, COut) :- - builtin(H), !, - call((\+ H)), - exact(T, CIn, COut). - -exact([\+ H |T], CIn, COut) :- !, - list2and(HL, H), - findall(D, find_deriv(HL, D), L), - choose_clauses(CIn, L, C1), - exact(T, C1, COut). - -exact([H|T], CIn, COut) :- - builtin(H), !, - call(H), - exact(T, CIn, COut). - -exact([H|T], CIn, COut) :- - def_rule(H, B), - append(B, T, NG), - exact(NG, CIn, COut). - -exact([H|T], CIn, COut) :- - find_rule(H, (R, S, N), B, CIn), - solve_pres(R, S, N, B, T, CIn, COut). - - - -solve_pres(R, S, N, B, T, CIn, COut) :- - member_eq((N, R, S), CIn), !, - append(B, T, NG), - exact(NG, CIn, COut). - -solve_pres(R, S, N, B, T, CIn, COut) :- - append(CIn, [(N, R, S)], C1), - append(B, T, NG), - exact(NG, C1, COut). - - - -/* find_rule(G, (R, S, N), Body, C) - * -------------------------------- - * This predicate takes a goal G and the current C set and returns the index R - * of a disjunctive rule resolving with G together with the index N of the - * resolving head, the substitution S and the Body of the rule. - */ -find_rule(H, (R, S, N), Body, C) :- - rule(H, _P, N, R, S, _NH, _Head, Body), - not_already_present_with_a_different_head(N, R, S, C). - -/* run_file(BDDFile, BDDParFile, Prob) - * ----------------------------------- - * This predicate calls for the resolution of a BDD via file. - */ -run_file(BDDFile, BDDParFile, Prob) :- - ResultFile = 'result.txt', - library_directory(Dir), - setting(timeout, BDDTime), - (BDDTime = no -> - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' > ', ResultFile], Command); - atomic_concat([Dir, '/LPADBDD -l ', BDDFile, ' -i ', BDDParFile,' -t ', BDDTime,' > ', ResultFile], Command)), - - %statistics(walltime,_), - - shell(Command, Return), - (Return =\= 0 -> - Status = timeout, - Prob = Status; - - see(ResultFile), - read(elapsed_construction(_TimeConstruction)), - read(probability(Prob)), - read(elapsed_traversing(_TimeTraversing)), - seen, - - %write(probability(Prob)),nl, - %read(_), - %delete_file(ResultFile), - - Status = ok - % format("Construction time ~f traversing time ~f~Number",[TimeConstruction, TimeTraversing]) - ). - - %statistics(walltime,[_,E3]), - %format(user,'~w ms BDD processing~Number',[E3]), - % format("Status ~a~Number",[Status]). - - - -/* insert_list_ptree([Head|Tail], Trie) - * ------------------------------------ - * This predicate inserts the given list in a trie. - */ -insert_list_ptree([], _Trie). - -insert_list_ptree([Head|Tail], Trie) :- - reverse(Head, Head1), - insert_ptree(Head1, Trie), - insert_list_ptree(Tail, Trie). diff --git a/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base b/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base deleted file mode 100644 index a429fc598..000000000 --- a/packages/cplint/approx/.svn/text-base/exact_mem.pl.svn-base +++ /dev/null @@ -1,189 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File best.pl - * Goal oriented interpreter for LPADs based on SLDNF - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -/* DA MODIFICARE AFFINCHE' USI IL NUOVO CPLINT_INT */ -/* PARTE BDD IN UN FILE SEPARATO? */ - - -:- dynamic rule/4, def_rule/2. - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ -:- use_module(library(lists)). -:- use_module(library(ugraphs)). -:- use_module(params). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* INITIALIZATION - * -------------- - * The following predicate enables the cplint specific features for the program. - */ -:- load_foreign_files(['cplint'], [], init_my_predicates). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* solve(GoalsList, Prob, ResTime, BddTime) - * ---------------------------------------- - * This predicate computes the probability of a given list of goals using an - * exact algorithm. It also returns the number of handled BDDs (trivial but - * present for simmetry with other solving predicates), CPUTime spent in - * performing resolution and in handling the BDDs. - * - * INPUT - * - GoalsList: given list of goal to work on. - * - * OUTPUT - * - Prob: the resulting exact probability for the given list of goals. - * - Count: number of BDDs handled by the algorithm (trivial, since it's always 1). - * - ResTime: cpu time spent on performing resolution. - * - BddTime: cpu time spent on handling BDDs. - */ -solve(GoalsList, Prob, ResTime, BddTime) :- - % Resetting the clocks... - statistics(walltime, [_, _]), - % Performing resolution... - findall(Deriv, exact(GoalsList, Deriv), List), - % Taking elapsed times... - statistics(walltime, [_, ElapResTime]), - ResTime is ElapResTime/1000, - % Building and solving equivalent bdds... - build_formula(List, Formula, [], Var), - var2numbers(Var, 0, NewVar), - (setting(save_dot, true) -> - format("Variables: ~p~n", [Var]), - compute_prob(NewVar, Formula, Prob, 1); - compute_prob(NewVar, Formula, Prob, 0)), - - % Taking elapsed times - statistics(walltime, [_, ElapBddTime]), - BddTime is ElapBddTime/1000. - -/* exact(GoalsList, CIn, COut) takes a list of goals and an input C set -and returns an output C set -The C set is a list of triple (N, R, S) where -- N is the index of the head atom used, starting from 0 -- R is the index of the non ground rule used, starting from 1 -- S is the substitution of rule R, in the form of a list whose elements - are of the form 'VarName'=value -*/ -exact(GoalsList, Deriv) :- - exact(GoalsList, [], Deriv). - -exact([], C, C) :- !. - -exact([bagof(V, EV^G, L)|T], CIn, COut) :- !, - list2and(GL, G), - bagof((V, C), EV^exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L, [], C1), - remove_duplicates_eq(C1, C2), - exact(T, C2, COut). - -exact([bagof(V, G, L)|T], CIn, COut) :- !, - list2and(GL, G), - bagof((V, C), exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L, [], C1), - remove_duplicates_eq(C1, C2), - exact(T, C2, COut). - -exact([setof(V, EV^G, L)|T], CIn, COut) :- !, - list2and(GL, G), - setof((V, C), EV^exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L1, [], C1), - remove_duplicates(L1, L), - exact(T, C1, COut). - -exact([setof(V, G, L)|T], CIn, COut) :- !, - list2and(GL, G), - setof((V, C), exact(GL, CIn, C), LD), - length(LD, N), - build_initial_graph(N, GrIn), - build_graph(LD, 0, GrIn, Gr), - clique(Gr, Clique), - build_Cset(LD, Clique, L1, [], C1), - remove_duplicates(L1, L), - exact(T, C1, COut). - -exact([\+ H|T], CIn, COut) :- - builtin(H), !, - call((\+ H)), - exact(T, CIn, COut). - -exact([\+ H |T], CIn, COut) :- !, - list2and(HL, H), - findall(D, find_deriv(HL, D), L), - choose_clauses(CIn, L, C1), - exact(T, C1, COut). - -exact([H|T], CIn, COut) :- - builtin(H), !, - call(H), - exact(T, CIn, COut). - -exact([H|T], CIn, COut) :- - def_rule(H, B), - append(B, T, NG), - exact(NG, CIn, COut). - -exact([H|T], CIn, COut) :- - find_rule(H, (R, S, N), B, CIn), - solve_pres(R, S, N, B, T, CIn, COut). - - - -solve_pres(R, S, N, B, T, CIn, COut) :- - member_eq((N, R, S), CIn), !, - append(B, T, NG), - exact(NG, CIn, COut). - -solve_pres(R, S, N, B, T, CIn, COut) :- - append(CIn, [(N, R, S)], C1), - append(B, T, NG), - exact(NG, C1, COut). - - - -/* find_rule(G, (R, S, N), Body, C) - * -------------------------------- - * This predicate takes a goal G and the current C set and returns the index R - * of a disjunctive rule resolving with G together with the index N of the - * resolving head, the substitution S and the Body of the rule. - */ -find_rule(H, (R, S, N), Body, C) :- - rule(H, _P, N, R, S, _NH, _Head, Body), - not_already_present_with_a_different_head(N, R, S, C). diff --git a/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base b/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base deleted file mode 100644 index 049780a99..000000000 --- a/packages/cplint/approx/.svn/text-base/montecarlo.pl.svn-base +++ /dev/null @@ -1,275 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File: montecarlo.pl - * Solves LPADs with Monte Carlo (main predicate: solve(Goals, Prob, Samples, ResTime, BddTime) - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -/* EXTERNAL FILE - * ------------- - * The following libraries are required by the program to work fine. - */ - -:- dynamic rule/4, def_rule/2, randx/1, randy/1, randz/1. - -:- use_module(library(lists)). -:- use_module(library(random)). -:- use_module(library(ugraphs)). -:- use_module(params). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* SOLVING PREDICATES - * ------------------ - * The predicates in this section solve any given problem with several class of - * algorithms. - * - * Note: the original predicates (no more need and eligible to be deleted) have - * been moved to the end of the file. - */ - -/* Starting seed. */ -randx(1). -randy(1). -randz(1). - -/* newsample - * --------- - * This predicate programmatically generates and sets a new seed for the - * algorithm. - */ -newsample :- - retract(randx(X)), - randy(Y), - randz(Z), - (X =< 30269 -> - SuccX is X + 1, - assert(randx(SuccX)); - assert(randx(1)), - retract(randy(_)), - (Y =< 30307 -> - SuccY is Y + 1, - assert(randy(SuccY)); - assert(randy(1)), - retract(randz(_)), - (Z =< 30323 -> - SuccZ is Z + 1, - assert(randz(SuccZ)); - assert(randz(1))))), - setrand(rand(X, Y, Z)). - - -/* solve(Goals, Samples, Time, Lower, Prob, Upper) - * ----------------------------------------------- - * This predicate calls the Monte Carlo solving method for the current problem. - * It requires the Goals to fulfil and returns the number of Samples considered, - * the Time required, the extimated Probability and the Lower and Upper bounds. - * - * INPUT - * - Goals: given list of goals to fulfil. - * - * OUTPUT - * - Samples: number of samples considered to solve the problem. - * - Time: time required to solve the problem. - * - Lower: lower end of the confidence interval. - * - Prob: extimated probability. - * - Upper: upper end of the confidence interval. - */ -solve(Goals, Samples, Time, Lower, Prob, Upper) :- - % Retrieving functional parameters... - setting(k, K), - setting(min_error, MinError), - % Resetting the clocks... - statistics(walltime, [_, _]), - % Performing resolution... - montecarlo(0, 0, Goals, K, MinError, Samples, Lower, Prob, Upper), - % Taking elapsed times... - statistics(walltime, [_, ElapTime]), - % Setting values... - Time is ElapTime/1000. - - - -/* montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) - * --------------------------------------------------------------------------- - * This tail recursive predicate solves the problem currently in memory with a - * Monte Carlo approach. - * It requires the number of samples and successes so far (Count and Success), - * the desired list of Goals to fulfil, the number K of samples to consider at - * once and the threshold MinError for the binomial proportion confidence - * interval. - * It returns the total number of Samples considered, the Lower and Upper ends - * of the the binomial proportion confidence interval and the extimated Prob. - * - * INPUT - * - Count: number of samples considered so far. - * - Success: number of successfull samples considered so far. - * - Goals: list of goals to fulfil. - * - K: number of samples to consider at once. - * - MinError: threshold for the binomial proportion confidence interval. - * - * OUTPUT - * - Samples: total number of samples considered. - * - Lower: lower end of the the binomial proportion confidence interval. - * - Prob: extimated probability. - * - Upper: upper end of the the binomial proportion confidence interval. - * - * NB: This method is based on the binomial proportion confidence interval and - * the Brown's rule of thumb to avoid the case the sample proportion is - * exactly 0.0 or 1.0 and doesn't make use of BDDs. - */ -montecarlo(Count, Success, Goals, K, MinError, Samples, Lower, Prob, Upper) :- - /* Decomment the following line if you want to test the algorithm with an - incremental seed for each sample. - newsample, - */ - main(Goals, [], _Explan, Valid), - N is Count + 1, - S is Success + Valid, - (N mod K =:= 0 -> -% format("Advancement: ~t~d/~d~30+~n", [S, N]), - P is S / N, - D is N - S, - Semi is 2 * sqrt(P * (1 - P) / N), - Int is 2 * Semi, - /* N * P > 5; N * S / N > 5; S > 5 - * N (1 - P) > 5; N (1 - S / N) > 5; N (N - S) / N > 5; N - S > 5 - */ - ((S > 5, D > 5, (Int < MinError; Int =:= 0)) -> - Samples is N, - Lower is P - Semi, - Prob is P, - Upper is P + Semi; - montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)); - montecarlo(N, S, Goals, K, MinError, Samples, Lower, Prob, Upper)). - - - -/* null - * ---- - * This is dummy predicate to use sparingly when needed. - * Typical uses are as spying predicate during tracing or as dead branch in - * ( -> ; ) predicate. - */ -null. - - - -/* main(Goals, Explan0, Explan1, Valid) - * ------------------------------------ - * This tail recursive predicate looks for a solution to the given Goals - * starting from the given Explan0 and returns the final Explan and 1 (0 otherwise) if it is a - * Valid sample for Montecarlo. - */ -main([], Explan, Explan, 1). - -main([\+ Goal|Tail], Explan0, Explan1, Valid) :- - builtin(Goal), !, - (call((\+ Goal)) -> - main(Tail, Explan0, Explan1, Valid); - Explan1 = Explan0, - Valid = 0). - -main([Goal|Tail], Explan0, Explan1, Valid) :- - builtin(Goal), !, - (call(Goal) -> - main(Tail, Explan0, Explan1, Valid); - Explan1 = Explan0, - Valid = 0). - -main([Goal|Tail], Explan0, Explan1, Valid) :- - findall((IsSample, Goals, Step), explore([Goal|Tail], Explan0, IsSample, Goals, Step), List), - cycle(List, Explan0, Explan1, Valid). - - - -/* explore([Goal|Tail], Explan, Valid, Goals, Step) - * ------------------------------------------------ - * This predicate looks for a Body and the Step to reach it from the given Goal - * and Explan and returns 1 (0 otherwise) if they are a Valid sample for - * Montecarlo. - * Please note that Body and Step are meaningfull only when Valid is 1. - * - * This comment has to be fixed. - */ -explore([Goal|Tail], _Explan, 1, Goals, []) :- - def_rule(Goal, Body), - append(Body, Tail, Goals). - -explore([Goal|Tail], Explan, Valid, Goals, Step) :- - findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)), - append(Body, Tail, Goals), - (member_eq((HeadID, RuleID, Subst), Explan) -> - Step = []; - Step = [(HeadID, RuleID, Subst)]). - - - -/* findrule(Goal, Explan, Valid, Body, (HeadID, RuleID, Subst)) - * --------------------------------------------------------------- - * This predicate finds a rule that matches with the given Goal and Explan and - * returns 1 (0 otherwise) if it is a Valid sample for Montecarlo. - * If the sample is Valid, the other return parameters are also meaningfull and - * are the Body and (RuleID, Subst, HeadIS) of the rule that matches with the - * given Goal and Explan. - * - * This comment has to be fixed. - */ -findrule(Goal, Explan, Valid, Body, (HeadId, RuleId, Subst)) :- - rule(Goal, _Prob, Required, RuleId, Subst, _Heads, HeadsList, Body), - sample(HeadsList, HeadId), - not_already_present_with_a_different_head(HeadId, RuleId, Subst, Explan), - (HeadId =:= Required -> - Valid = 1; - Valid = 0). - - - -/* sample(Heads, RuleId, HeadId, Subst) - * ------------------------------------ - * This tail recursive predicate samples a random head among the given Heads of - * the given RuleId and returns its HeadId and Subst. - */ -sample(HeadList, HeadId) :- - random(Prob), - sample(HeadList, 0, 0, Prob, HeadId), !. - -sample([_HeadTerm:HeadProb|Tail], Index, Prev, Prob, HeadId) :- - Succ is Index + 1, - Next is Prev + HeadProb, - (Prob =< Next -> - HeadId = Index; - sample(Tail, Succ, Next, Prob, HeadId)). - - - -/* cycle([(IsSample, Body, [Step])|Tail], Explan0, Explan1, Found) - * ----------------------------------------------------------------- - * This tail recursive predicate analyzes the given Body and Step to reach it - * and returns 0 as it's not a Valid sample for Montecarlo. - * If it is Valid, it looks for a solution to the Body and the given Goals - * starting from the Step and the given Explan and returns 1 if it finds a - * Valid one. - * If it does not find it, it considers the next Body and Step and returns their - * Valid value. - * - * NB: This comment needs to be updated. - */ -cycle([], Explan, Explan, 0). - -cycle([(0, _Goals, Step)|Tail], Explan0, Explan1, IsSample) :- !, - append(Step, Explan0, Explan2), - cycle(Tail, Explan2, Explan1, IsSample). - -cycle([(1, Goals, Step)|Tail], Explan0, Explan1, IsSample) :- - append(Step, Explan0, Explan), - main(Goals, Explan, Explan2, Valid), - (Valid == 1 -> - Explan1 = Explan2, - IsSample = 1; - cycle(Tail, Explan2, Explan1, IsSample)). diff --git a/packages/cplint/approx/.svn/text-base/params.pl.svn-base b/packages/cplint/approx/.svn/text-base/params.pl.svn-base deleted file mode 100644 index d3470e49f..000000000 --- a/packages/cplint/approx/.svn/text-base/params.pl.svn-base +++ /dev/null @@ -1,122 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File: params.pl - * Defines and sets parameters needed by other predicates (main: set). - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic setting/2. - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - -/* PARAMETER LIST - * -------------- - * The following list of parameters declares a few constants used along the - * program. - * The default value for each parameter can be changed using the following - * predicate: - * - * set(Parameter, Value). - */ - -/* epsilon_parsing - * --------------- - * This parameter shows the probability's granularity during parsing. - * - * Default value: 0.00001 - * Applies to: parsing - */ -setting(epsilon_parsing, 0.00001). - -/* ground_body - * ----------- - * This parameter tells if both the head and the body of each clause must be - * ground, or else the head only. - * In case the body contains variables not present in the head, it represents - * an existential event. - * - * Default value: false - * Applies to: parsing - */ -setting(ground_body, false). - -/* k - * - - * This parameter shows the amount of items of the same type to consider at once. - * - * Default value: 64 - * Applies to: bestfirst, bestk, montecarlo - */ -setting(k, 64). - -/* min_error - * --------- - * This parameter shows the threshold for the probability interval. - * - * Default value: 0.01 - * Applies to: bestfirst, montecarlo - */ -setting(min_error, 0.01). - -/* prob_bound - * ---------- - * This parameter shows the initial probability bound in a probability bounded - * method. - * - * Default value: 0.01 - * Applies to: deepit - */ -setting(prob_bound, 0.001). - -/* prob_step - * --------- - * This parameter shows the probability deepening step in a probability bounded - * method. - * - * Default value: 0.001 - * Applies to: bestfirst, bestk - */ -setting(prob_step, 0.001). - -/* save_dot - * -------- - * This parameter tells if a .dot file for variables has be created. - * - * Default value: false - * Applies to: bestfirst, bestk, exact - */ -setting(save_dot, false). - -/* timeout - * ------- - * This parameter shows the time to wait before killing a bdd solving process. - * - * Default value: 300 - * Applies to: bestfirst, bestk, exact - */ -setting(timeout, 300). - - - - - -/* PREDICATES - * ---------- - * The predicates in this section interact with the parameters defined above. - */ - -/* set(Parameter, Value) - * --------------------- - * This predicate drops any previously saved value for the given parameter and - * associates it to the new given value. - * - * INPUT - * - Parameter: target parameter for the given new value. - * - Value: new value to assign to the given parameter. - */ -set(Parameter, Value) :- - retract(setting(Parameter, _)), - assert(setting(Parameter, Value)). diff --git a/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base b/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base deleted file mode 100644 index 0e32ddaeb..000000000 --- a/packages/cplint/approx/.svn/text-base/parsing.pl.svn-base +++ /dev/null @@ -1,344 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File: parsing.pl - * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -:- use_module(params). -:- use_module(utility). - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* parse(File) - * ----------- - * This predicate parses the given .cpl file. - * - * Note: it can be called more than once without exiting yap - * - * INPUT - * - File: .cpl file to parse, without extension. - */ -parse(File) :- - atom_concat(File, '.cpl', FileName), - open(FileName, read, FileHandle), - read_clauses(FileHandle, Clauses), - close(FileHandle), - retractall(rule_by_num(_, _, _, _, _)), - retractall(rule(_, _, _, _, _, _, _, _)), - retractall(def_rule(_, _)), - process_clauses(Clauses, 1). - - - - - - - -/* assert_rules() - * -------------- - * This tail recursive predicate parses the given list of (Head:Prob) couples - * and stores them incrementally as rules along with the other parameters. - * - * INPUT - * - Head: current head part. - * - Prob: probability of the current head part. - * - Index: index of the current head part. - * - Subst: substitution for the current head part. - * - Choices: list of current head parts indexes. - * - HeadList: complete head or list of its parts. - * - BodyList: complete body or list of its parts. - */ -assert_rules([], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. % Closing condition. - -assert_rules(['':_Prob], _Index, _HeadList, _BodyList, _Choices, _Id, _Subst) :- !. - -assert_rules([Head:Prob|Tail], Index, HeadList, BodyList, Choices, Id, Subst) :- - assertz(rule(Head, Prob, Index, Id, Subst, Choices, HeadList, BodyList)), - Next is Index + 1, - assert_rules(Tail, Next, Id, Subst, Choices, HeadList, BodyList). - - - -delete_var(_Var, [], []). - -delete_var(Var, [Current|Tail], [Current|Next]) :- - Var \== Current, !, - delete_var(Var, Tail, Next). - -delete_var(_Var, [_Head|Tail], Tail). - - - -extract_vars(Variable, Var0, Var1) :- - var(Variable), !, - (member_eq(Variable, Var0) -> - Var1 = Var0; - append(Var0, [Variable], Var1)). - -extract_vars(Term, Var0, Var1) :- - Term=..[_F|Args], - extract_vars_list(Args, Var0, Var1). - - - -extract_vars_clause(end_of_file, []). - -extract_vars_clause(Clause, VarNames, Couples) :- - (Clause = (Head :- _Body) -> - true; - Head = Clause), - extract_vars(Head, [], Vars), - pair(VarNames, Vars, Couples). - - - -extract_vars_list([], Var, Var). - -extract_vars_list([Term|Tail], Var0, Var1) :- - extract_vars(Term, Var0, Var), - extract_vars_list(Tail, Var, Var1). - - - -get_var(Var, [Var]) :- - var(Var), !. % Succeeds if Var is currently a free variable, otherwise fails. - -get_var(Var, Value) :- - Var=..[_F|Args], - get_var_list(Args, Value). - - - -get_var_list([], []). - -get_var_list([Head|Tail], [Head|Next]) :- - var(Head), !, - get_var_list(Tail, Next). - -get_var_list([Head|Tail], Vars) :- !, - get_var(Head, Var), - append(Var, Next, Vars), - get_var_list(Tail, Next). - - - -/* ground_prob(HeadList) - * --------------------- - * This tail recursive predicate verifies if the given HeadList is ground. - * - * INPUT - * - HeadList: list of heads to verify its groundness. - */ -ground_prob([]). - -ground_prob([_Head:ProbHead|Tail]) :- - ground(ProbHead), % Succeeds if there are no free variables in the term ProbHead. - ground_prob(Tail). - - - -pair(_VarName, [], []). - -pair([VarName = _Var|TailVarName], [Var|TailVar], [VarName = Var|Tail]) :- - pair(TailVarName, TailVar, Tail). - - - -/* process_head(HeadList, CompleteHeadList) - * ---------------------------------------- - * Note: if the annotation in the head are not ground, the null atom is not - * added and the eventual formulas are not evaluated. - */ -process_head(HeadList, GroundHeadList) :- - ground_prob(HeadList), !, - process_head_ground(HeadList, 0, GroundHeadList); - -process_head(HeadList, HeadList). - - - -/* process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) - * ---------------------------------------------------------------- - */ -process_head_ground([Head:ProbHead], Prob, [Head:ProbHead|Null]) :- - ProbLast is 1 - Prob - ProbHead, - setting(epsilon_parsing, Eps), - EpsNeg is - Eps, - ProbLast > EpsNeg, - (ProbLast > Eps -> - Null = ['':ProbLast]; - Null = []). - -process_head_ground([Head:ProbHead|Tail], Prob, [Head:ProbHead|Next]) :- - ProbNext is Prob + ProbHead, - process_head_ground(Tail, ProbNext, Next). - - - - - - - - - - - - - - - - - -/* process_body(BodyList, Vars0, Vars1) - * ------------------------------------ - * Note: setof must have a goal in the form B^G, where B is a term containing - * the existential variables. - */ -process_body([], Vars, Vars). - -process_body([setof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, - get_var(A, VarsA), - get_var(B, VarsB), - remove_vars(VarsA, Vars0, Vars3), - remove_vars(VarsB, Vars3, Vars2), - process_body(Tail, Vars2, Vars1). - -process_body([setof(A, _G, _L)|Tail], Vars0, Vars1) :- !, - get_var(A, VarsA), - remove_vars(VarsA, Vars0, Vars2), - process_body(Tail, Vars2, Vars1). - -process_body([bagof(A, B^_G, _L)|Tail], Vars0, Vars1) :- !, - get_var(A, VarsA), - get_var(B, VarsB), - remove_vars(VarsA, Vars0, Vars3), - remove_vars(VarsB, Vars3, Vars2), - process_body(Tail, Vars2, Vars1). - -process_body([bagof(A, _G, _L)|Tail], Vars0, Vars1) :- !, - get_var(A, VarsA), - remove_vars(VarsA, Vars0, Vars2), - process_body(Tail, Vars2, Vars1). - -process_body([_Head|Tail], Vars0, Vars1) :- !, - process_body(Tail, Vars0, Vars1). - - - - - - - -process_clauses([(end_of_file, [])], _Id). - -/* NB: il seguente predicato è stato commentato perchè usa predicati non conformi - * a quelli attesi (vedi 'rule\5'). - * / -process_clauses([((Head :- Body), Value)|Tail], Id) :- - Head=uniform(A, P, L), !, - list2and(BodyList, Body), - process_body(BodyList, Value, BodyListValue), - remove_vars([P], BodyListValue, V2), - append(BodyList, [length(L, Tot), nth0(Number, L, P)], BL1), - append(V2, ['Tot'=Tot], V3), - assertz(rule(Id, V3, _NH, uniform(A:1/Tot, L, Number), BL1)), - assertz(rule_uniform(A, Id, V3, _NH, 1/Tot, L, Number, BL1)), - N1 is Id+1, - process_clauses(Tail, N1). */ - -process_clauses([((Head :- Body), Value)|Tail], Id) :- - Head = (_;_), !, - list2or(HeadListOr, Head), - process_head(HeadListOr, HeadList), - list2and(BodyList, Body), - process_body(BodyList, Value, BodyListValue), - length(HeadList, LH), - listN(0, LH, NH), - assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), - assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), - N1 is Id+1, - process_clauses(Tail, N1). - -process_clauses([((Head :- Body), Value)|Tail], Id) :- - Head = (_:_), !, - list2or(HeadListOr, Head), - process_head(HeadListOr, HeadList), - list2and(BodyList, Body), - process_body(BodyList, Value, BodyListValue), - length(HeadList, LH), - listN(0, LH, NH), - assert_rules(HeadList, 0, HeadList, BodyList, NH, Id, BodyListValue), - assertz(rule_by_num(Id, BodyListValue, NH, HeadList, BodyList)), - N1 is Id+1, - process_clauses(Tail, N1). - -process_clauses([((Head :- Body), _V)|Tail], Id) :- !, - list2and(BodyList, Body), - assert(def_rule(Head, BodyList)), - process_clauses(Tail, Id). - -process_clauses([(Head, Value)|Tail], Id) :- - Head=(_;_), !, - list2or(HeadListOr, Head), - process_head(HeadListOr, HeadList), - length(HeadList, LH), - listN(0, LH, NH), - assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), - assertz(rule_by_num(Id, Value, NH, HeadList, [])), - N1 is Id+1, - process_clauses(Tail, N1). - -process_clauses([(Head, Value)|Tail], Id) :- - Head=(_:_), !, - list2or(HeadListOr, Head), - process_head(HeadListOr, HeadList), - length(HeadList, LH), - listN(0, LH, NH), - assert_rules(HeadList, 0, HeadList, [], NH, Id, Value), - assertz(rule_by_num(Id, Value, NH, HeadList, [])), - N1 is Id+1, - process_clauses(Tail, N1). - -process_clauses([(Head, _V)|Tail], Id) :- - assert(def_rule(Head, [])), - process_clauses(Tail, Id). - - - -read_clauses(Stream, Clauses) :- - (setting(ground_body, true) -> - read_clauses_ground_body(Stream, Clauses); - read_clauses_exist_body(Stream, Clauses)). - - - -read_clauses_exist_body(Stream, [(Clause, Vars)|Next]) :- - read_term(Stream, Clause, [variable_names(VarNames)]), - extract_vars_clause(Clause, VarNames, Vars), - (Clause = end_of_file -> - Next = []; - read_clauses_exist_body(Stream, Next)). - - - -read_clauses_ground_body(Stream, [(Clause, Vars)|Next]) :- - read_term(Stream, Clause, [variable_names(Vars)]), - (Clause = end_of_file -> - Next = []; - read_clauses_ground_body(Stream, Next)). - - - -remove_vars([], Vars, Vars). - -remove_vars([Head|Tail], Vars0, Vars1) :- - delete_var(Head, Vars0, Vars2), - remove_vars(Tail, Vars2, Vars1). diff --git a/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base b/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base deleted file mode 100644 index d0e724167..000000000 --- a/packages/cplint/approx/.svn/text-base/tptreefile.pl.svn-base +++ /dev/null @@ -1,727 +0,0 @@ -%%% -*- Mode: Prolog; -*- -:-source. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% prefix-trees for managing a DNF -% remembers shortest prefix of a conjunction only (i.e. a*b+a*b*c results in a*b only, but b*a+a*b*c is not reduced) -% children are sorted, but branches aren't (to speed up search while keeping structure sharing from proof procedure) -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- module(ptree,[init_ptree/1, - delete_ptree/1, - rename_ptree/2, - member_ptree/2, - enum_member_ptree/2, - insert_ptree/2, - delete_ptree/2, - edges_ptree/2, - count_ptree/2, - prune_check_ptree/2, - empty_ptree/1, - merge_ptree/3, - bdd_ptree/3, - bdd_ptree_map/4 - ]). -:-source. -:- use_module(library(tries), - [ - trie_open/1, - trie_close/1, - trie_stats/4, - trie_check_entry/3, - trie_get_entry/2, - trie_put_entry/3, - trie_remove_entry/1, - trie_usage/4, - trie_dup/2, - trie_join/2, - trie_traverse/2 - ]). - -:- use_module(library(ordsets), - [ - ord_subset/2 - ]). - -:- style_check(all). -%:- yap_flag(unknown,error). - -%:- use_module(flags,[problog_flag/2]). -:- ensure_loaded(library(lists)). -:- ensure_loaded(library(system)). - -% name lexicon external - internal -sym(1,tree1) :- !. -sym(2,tree2) :- !. -sym(3,tree3) :- !. -sym(N,AN) :- atomic_concat([tree,N],AN). - -%%%%%%%%%%%%%%%%%%%%%%%% -% ptree basics -%%%%%%%%%%%%%%%%%%%%%%%% - -init_ptree(ID) :- - sym(ID,Sym), - trie_open(Trie), - nb_setval(Sym, Trie). - -delete_ptree(ID) :- - sym(ID,Sym), - nb_getval(Sym, Trie), !, - trie_close(Trie), - trie_open(NewTrie), - nb_setval(Sym, NewTrie). -delete_ptree(_). - -rename_ptree(OldID,NewID) :- - sym(OldID,OldSym), - sym(NewID,NewSym), - nb_getval(OldSym, Trie), - nb_set_shared_val(NewSym, Trie). - -empty_ptree(ID) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_usage(Trie, 0, 0, 0). - - -%%%%%%%%%%%%%%%%%%%%%%%% -% member -%%%%%%%%%%%%%%%%%%%%%%%% - -% non-backtrackable (to check) -member_ptree(List,ID) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_check_entry(Trie, List, _). - -% backtrackable (to list) -enum_member_ptree(ID,List) :- - sym(ID,Sym), - nb_getval(Sym, Tree), - trie_path(Tree, List). - -trie_path(Tree, List) :- - trie_traverse(Tree,Ref), - trie_get_entry(Ref, List). - -%%%%%%%%%%%%%%%%%%%%%%%% -% insert conjunction -%%%%%%%%%%%%%%%%%%%%%%%% -insert_ptree(true,ID) :- - sym(ID,Sym), - !, - nb_getval(Sym, Trie), - trie_close(Trie), - trie_open(NTrie), - trie_put_entry(NTrie, true, _). -insert_ptree(List,ID) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_put_entry(Trie, List, _). - -%%%%%%%%%%%%%%%%%%%%%%%% -% delete conjunction -%%%%%%%%%%%%%%%%%%%%%%%% -delete_ptree(List,ID) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_check_entry(Trie, List, Ref), - trie_remove_entry(Ref). - - -%%%%%%%% -% return list -Edges of all edge labels in ptree -% doesn't use any heuristic to order those for the BDD -% (automatic reordering has to do the job) -%%%%%%%%% -edges_ptree(ID,[]) :- - empty_ptree(ID), - !. -edges_ptree(ID,[]) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_check_entry(Trie, true, _), - !. -edges_ptree(ID,Edges) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - %( - setof(X, trie_literal(Trie, X), Edges).%-> - /* true - ; - Edges=[] - ).*/ - -trie_literal(Trie, X) :- - trie_traverse(Trie,Ref), - trie_get_entry(Ref, List), - member(X, List). - -%%%%%%%% -% number of conjunctions in the tree -%%%%%%%%% - -count_ptree(ID,N) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_usage(Trie, N, _, _). - -%%%%%%%% -% check whether some branch of ptree is a subset of conjunction List -% useful for pruning the search for proofs (optional due to time overhead) -% currently not implemented, just fails -%%%%%%% - -prune_check_ptree(_List,_TreeID) :- - format(user,'FAIL: prune check currently not supported~n',[]), - flush_output(user), - fail. - -%%%%%%%%%%%%% -% merge two ptrees -% - take care not to loose proper prefixes that are proofs! -%%%%%%%%%%%%%%% - -merge_ptree(ID1,_,ID3) :- - sym(ID1,Sym1), - sym(ID3,Sym3), - nb_getval(Sym1, T1), - trie_check_entry(T1, true, _), - !, - trie_open(T3), - trie_put_entry(T3, true, _), - nb_setval(Sym3, T3). -merge_ptree(_,ID2,ID3) :- - sym(ID2,Sym2), - sym(ID3,Sym3), - nb_getval(Sym2, T2), - trie_check_entry(T2, true, _), - !, - trie_open(T3), - trie_put_entry(T3, true, _), - nb_setval(Sym3, T3). -merge_ptree(ID1,ID2,ID3) :- - sym(ID1,Sym1), - sym(ID2,Sym2), - sym(ID3,Sym3), - nb_getval(Sym1, T1), - nb_getval(Sym2, T2), - trie_dup(T1, T3), - trie_join(T3,T2), - nb_setval(Sym3, T3). - - -%%%%%%%%%%%%%%%%%%%%%%%% -% write BDD info for given ptree to file -% - initializes leaf BDDs (=variables) first -% - then compresses ptree to exploit subtree sharing -% - bdd_pt/1 does the work on the structure itself -%%%%%%%%%%%%%%%%%%%%%%%% - -bdd_ptree(ID,FileBDD,FileParam) :- - bdd_ptree_script(ID,FileBDD,FileParam), - eraseall(map), - eraseall(vars). - -% version returning variable mapping -bdd_ptree_map(ID,FileBDD,FileParam,FileMapping) :- - bdd_ptree_script(ID,FileBDD,FileParam), - findall(X,recorded(map,X,_),Map), - add_probs(Map,Mapping), - tell(FileMapping), - write(Mapping),write('.'), - told, - eraseall(map), - eraseall(vars). - -add_probs([],[]). -add_probs([m(R,S,Num,Name)|Map],[m(R,S,Num,Name,Prob)|Mapping]) :- - user:rule_by_num(R,S,_N,Head,_Body), - user:get_probs(Head,Prob), - add_probs(Map,Mapping). - -% number of variables may be to high: -% counted on trie, but conversion to old tree representation -% transforms A*B+A to A (prefix-test) -bdd_ptree_script(ID,FileBDD,FileParam) :- - assert(v_num(0)), - edges_ptree(ID,Edges), - compute_nvars(Edges,0,NVars,0,NBVars), - tell(FileParam), - bdd_vars_script(Edges), - - flush_output, - - told, - length(Edges,_VarCount), - assert(c_num(1)), - bdd_pt(ID,CT),!, - c_num(NN), - IntermediateSteps is NN-1, - tell(FileBDD), - format('@BDD1~n~w~n~w~n~w~n~w~n',[NVars,NBVars,0,IntermediateSteps]), - output_compressed_script_only(CT),!, - - told, - retractall(c_num(_)), - retractall(v_num(_)), - retractall(compression(_,_)). - -compute_nvars([],NV,NV,NBV,NBV). - -compute_nvars([(_V,R,S)|T],NV0,NV1,NBV0,NBV1):- - (recorded(vars,v(R,S),_)-> - compute_nvars(T,NV0,NV1,NBV0,NBV1) - ; - recorda(vars,v(R,S),_), - NV2 is NV0+1, - user:rule_by_num(R,S,_N,Head,_Body), - length(Head,L), - NBV2 is NBV0+integer(ceiling(log(L)/log(2))), - compute_nvars(T,NV2,NV1,NBV2,NBV1) - ). - -% write parameter file by iterating over all var/not(var) occuring in the tree -/*bdd_vars_script(Edges) :- - bdd_vars_script(Edges,0). -*/ -bdd_vars_script([]). -%%%% Bernd, changes for negated ground facts -/* -bdd_vars_script([(_V,R,S)|B],N) :- - recorded(map,m(R,S,_Num,_NameA),_),!, - bdd_vars_script(B,N). -*/ -bdd_vars_script([(_V,R,S)|B]) :- - (recorded(map,m(R,S,_Number,_NameA),_)-> - true - ; - user:rule_by_num(R,S,_N,Head,_Body), - user:get_probs(Head,P), - get_var_name(R,S,_Number,NameA), - length(Head,NV), - format('@~w~n~d~n',[NameA,NV]), - print_probs(P) - ), - bdd_vars_script(B). - -print_probs([H]):-!, - format("~f~n",[H]). - -print_probs([H|T]):- - format("~f ",[H]), - print_probs(T). - - -%%%%%%%%%%%%%%%%%%%%%%%% -% find top level symbol for script -%%%%%%%%%%%%%%%%%%%%%%%% - -% special cases: variable-free formulae -bdd_pt(ID,false) :- - empty_ptree(ID), - !, - once(retractall(c_num(_))), - once(assert(c_num(2))). -bdd_pt(ID,true) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_check_entry(Trie, true, _), - !, - once(retractall(c_num(_))), - once(assert(c_num(2))). - -% general case: transform trie to nested tree structure for compression -bdd_pt(ID,CT) :- - sym(ID,Sym), - nb_getval(Sym, Trie), - trie_to_tree(Trie, Tree), - compress_pt(Tree,CT). - -trie_to_tree(Trie, Tree) :- - findall(Path,trie_path(Trie, Path), Paths), - add_trees(Paths, [], Tree). - -add_trees([], Tree, Tree). -add_trees([List|Paths], Tree0, Tree) :- - ins_pt(List, Tree0, TreeI), - add_trees(Paths, TreeI, Tree). - -ins_pt([],_T,[]) :- !. -ins_pt([A|B],[s(A1,AT)|OldT],NewT) :- - compare(Comp, A1, A), - (Comp == = -> - (AT == [] -> - NewT=[s(A1,AT)|OldT] - ; - NewT = [s(A1,NewAT)|OldT], - ins_pt(B, AT, NewAT)) - ; - Comp == > -> - NewT = [s(A1,AT)|Tree], - ins_pt([A|B], OldT, Tree) - ; - NewT = [s(A,BTree),s(A1,AT)|OldT], - ins_pt(B,[],BTree) - ). -ins_pt([A|B],[],[s(A,NewAT)]) :- - ins_pt(B,[],NewAT). - -%%%%%%%%%%%% -% BDD compression: alternates and- and or-levels to build BDD bottom-up -% each sub-BDD will be either a conjunction of a one-node BDD with some BDD or a disjunction of BDDs -% uses the internal database to temporarily store a map of components -%%%%%%%%%%%% - -% T is completely compressed and contains single variable -% i.e. T of form x12 or ~x34 -compress_pt(T,TT) :- - atom(T), - test_var_name(T), - !, - get_next_name(TT), - assertz(compression(TT,[T])). -% T is completely compressed and contains subtrees -% i.e. T of form 'L56' -compress_pt(T,T) :- - atom(T). -% T not yet compressed -% i.e. T is a tree-term (nested list & s/2 structure) -% -> execute one layer of compression, then check again -compress_pt(T,CT) :- - \+ atom(T), - and_or_compression(T,IT), - compress_pt(IT,CT). - -% transform tree-term T into tree-term CT where last two layers have been processed -% i.e. introduce names for subparts (-> Map) and replace (all occurrenes of) subparts by this names -and_or_compression(T,CT) :- - and_comp(T,AT), - or_comp(AT,CT). - -% replace leaves that are single child by variable representing father-AND-child -and_comp(T,AT) :- - all_leaves_pt(T,Leaves), - compression_mapping(Leaves,Map), - replace_pt(T,Map,AT). - -% replace list of siblings by variable representing their disjunction -or_comp(T,AT) :- - all_leaflists_pt(T,Leaves), - compression_mapping(Leaves,Map), - replace_pt(T,Map,AT). - -all_leaves_pt(T,L) :- - all(X,some_leaf_pt(T,X),L). - -some_leaf_pt([s(A,[])|_],s(A,[])). -some_leaf_pt([s(A,L)|_],s(A,L)) :- - not_or_atom(L). -some_leaf_pt([s(_,L)|_],X) :- - some_leaf_pt(L,X). -some_leaf_pt([_|L],X) :- - some_leaf_pt(L,X). - -all_leaflists_pt(L,[L]) :- - atomlist(L),!. -all_leaflists_pt(T,L) :- - all(X,some_leaflist_pt(T,X),L),!. -all_leaflists_pt(_,[]). - -some_leaflist_pt([s(_,L)|_],L) :- - atomlist(L). -some_leaflist_pt([s(_,L)|_],X) :- - some_leaflist_pt(L,X). -some_leaflist_pt([_|L],X) :- - some_leaflist_pt(L,X). - -not_or_atom(T) :- - ( - T=not(T0) - -> - atom(T0); - atom(T) - ). - -atomlist([]). -atomlist([A|B]) :- - not_or_atom(A), - atomlist(B). - -% for each subtree that will be compressed, add its name -% only introduce 'L'-based names when subtree composes elements, store these in compression/2 for printing the script -compression_mapping([],[]). -compression_mapping([First|B],[N-First|BB]) :- - ( - First = s((V,R,S),[]) % subtree is literal -> use variable's name x17 from map (add ~ for negative case) - -> - recorded(map,m(R,S,_Num,Tmp),_), %check - atomic_concat([Tmp,'-',V],N) - ; - (First = s(A,L),not_or_atom(L)) % subtree is node with single completely reduced child -> use next 'L'-based name - -> (get_next_name(N), - assertz(compression(N,s(A,L)))) - ; - (First = [L],not_or_atom(L)) % subtree is an OR with a single completely reduced element -> use element's name - -> N=L - /*, - recorded(refc,m(L,RefC),Ref), - erase(Ref), - RefC1 is RefC+1, - recorda(refc,m(L,RefC1),_)*/ - ; - (atomlist(First), % subtree is an OR with only (>1) completely reduced elements -> use next 'L'-based name - get_next_name(N), - assertz(compression(N,First))) - ), - compression_mapping(B,BB). - -increase_counts([]). - -increase_counts([H|T]):- - recorded(refc,m(H,RC),Ref), - erase(Ref), - RC1 is RC+1, - recorda(refc,m(H,RC1),_), - increase_counts(T). - -compute_or([A],Node0,Node1):- - recorded(mapnodes,m(A,Node),_), - or(Node0,Node,Node1). - -compute_or([A,B|T],Node0,Node1):- - recorded(mapnodes,m(A,Node),_), - or(Node0,Node,Node2), - compute_or([B|T],Node2,Node1). - - -% replace_pt(+T,+Map,-NT) -% given the tree-term T and the Map of Name-Subtree entries, replace each occurence of Subtree in T with Name -> result NT -replace_pt(T,[],T). -replace_pt([],_,[]). -replace_pt(L,M,R) :- - atomlist(L), - member(R-L,M), - !. -replace_pt([L|LL],[M|MM],R) :- - replace_pt_list([L|LL],[M|MM],R). - -replace_pt_list([T|Tree],[M|Map],[C|Compr]) :- - replace_pt_single(T,[M|Map],C), - replace_pt_list(Tree,[M|Map],Compr). -replace_pt_list([],_,[]). - -replace_pt_single(s(A,T),[M|Map],Res) :- - atomlist(T), - member(Res-s(A,T),[M|Map]), - !. -replace_pt_single(s(A,T),[M|Map],s(A,Res)) :- - atomlist(T), - member(Res-T,[M|Map]), - !. -replace_pt_single(s(A,T),[M|Map],Res) :- - member(Res-s(A,T),[M|Map]), - !. -replace_pt_single(s(A,T),[M|Map],s(A,TT)) :- - replace_pt_list(T,[M|Map],TT). -replace_pt_single(A,_,A) :- - not_or_atom(A). - -output_compressed_script_only(false) :- - !, - format('L1 = FALSE~nL1~n',[]). -output_compressed_script_only(true) :- - !, - format('L1 = TRUE~nL1~n',[]). -output_compressed_script_only(T) :- - once(retract(compression(Short,Long))), - assertz(compression(Short,Long)), - (T = Short -> - format('~w = ',[Short]), - format_compression_script_only(Long), - format('~w~n',[Short]) - ; - format('~w = ',[Short]), - format_compression_script_only(Long), - output_compressed_script_only(T) - ). - -format_compression_script_only(s((V,R,S),B0)) :- - recorded(map,m(R,S,_Num,C),_), - atomic_concat([C,'-',V],C1), - format('~w * ~w~n',[C1,B0]). - -format_compression_script_only([A]) :- - format('~w~n',[A]). -format_compression_script_only([A,B|C]) :- - format('~w + ',[A]), - format_compression_script_only([B|C]). - - -%%%%%%%%%%%% -% output for script -% input argument is compressed tree, i.e. true/false or name assigned in last compression step -%%%%%%%%%%%% -output_compressed_script(false) :- - !. - %format('L1 = FALSE~nL1~n',[]). -output_compressed_script(true) :- - !. - %format('L1 = TRUE~nL1~n',[]). -% for each name-subtree pair, write corresponding line to script, e.g. L17 = x4 * L16 -% stop after writing definition of root (last entry in compression/2), add it's name to mark end of script -output_compressed_script(T) :- - once(retract(compression(Short,Long))), - (T = Short -> - % format('~w = ',[Short]), - format_compression_script(Long,Short) - % format('~w~n',[Short]) - ; - % format('~w = ',[Short]), - format_compression_script(Long,Short), - output_compressed_script(T)). - -format_compression_script(s((V,R,S),B0),Short) :-!, - % checkme - recorded(map,m(R,S,_Num,C),_), - atomic_concat([C,'-',V],C1), - recorded(mapnodes,m(C1,Node1),_), - recorded(mapnodes,m(B0,Node2),_), - % format('~w * ~w~n',[C1,B0]), - and(Node1,Node2,Node), - recorda(mapnodes,m(Short,Node),_), - recorded(refc,m(C1,RefC1),Ref1), - recorded(refc,m(B0,RefC2),Ref2), - erase(Ref1), - erase(Ref2), - RefC11 is RefC1-1, - RefC21 is RefC2-1, - (RefC11 =:=0-> - deref(Node1) - ; - recorda(refc,m(C1,RefC11),_) - ), - (RefC21 =:=0-> - deref(Node2) - ; - recorda(refc,m(B0,RefC21),_) - ). - -format_compression_script([H1],Short):-!, - % format('~w~n',[A]), - recorded(mapnodes,m(H1,Node1),_), - recorded(refc,m(H1,RefC1),Ref1), - erase(Ref1), - RefC11 is RefC1-1, - (RefC11 =:=0-> - deref(Node1) - ; - recorda(refc,m(H1,RefC11),_) - ), - recorda(mapnodes,m(Short,Node1),_). - -format_compression_script([H1,H2],Short):-!, - % format('~w + ~w~n',[H1,H2]), - recorded(mapnodes,m(H1,Node1),_), - recorded(refc,m(H1,RefC1),Ref1), - erase(Ref1), - RefC11 is RefC1-1, - recorded(mapnodes,m(H2,Node2),_), - recorded(refc,m(H2,RefC2),Ref2), - erase(Ref2), - RefC21 is RefC2-1, - or(Node1,Node2,Node), - (RefC11 =:=0-> - deref(Node1) - ; - recorda(refc,m(H1,RefC11),_) - ), - (RefC21 =:=0-> - deref(Node2) - ; - recorda(refc,m(H2,RefC21),_) - ), - recorda(mapnodes,m(Short,Node),_). - -format_compression_script([H1,H2,H3|T],Short):- - %format('~w + ~w +',[H1,H2]), - recorded(mapnodes,m(H1,Node1),_), - recorded(refc,m(H1,RefC1),Ref1), - erase(Ref1), - RefC11 is RefC1-1, - recorded(mapnodes,m(H2,Node2),_), - recorded(refc,m(H2,RefC2),Ref2), - erase(Ref2), - RefC21 is RefC2-1, - or(Node1,Node2,Node), - (RefC11 =:=0-> - deref(Node1) - ; - recorda(refc,m(H1,RefC11),_) - ), - (RefC21 =:=0-> - deref(Node2) - ; - recorda(refc,m(H2,RefC21),_) - ), - format_compression_script1([H3|T],Node,Short). - -format_compression_script1([A],Node1,Short) :-!, -% format('~w~n',[A]), - recorded(mapnodes,m(A,Node2),_), - recorded(refc,m(A,RefC),Ref), - erase(Ref), - or(Node1,Node2,Node), - deref(Node1), - recorda(mapnodes,m(Short,Node),_), - RefC1 is RefC-1, - (RefC1=:=0-> - deref(Node2) - ; - recorda(refc,m(A,RefC1),_) - ). - -format_compression_script1([A,B|C],Node1,Short) :- - format('~w + ',[A]), - recorded(mapnodes,m(A,Node2),_), - recorded(refc,m(A,RefC),Ref), - erase(Ref), - or(Node1,Node2,Node), - deref(Node1), - RefC1 is RefC-1, - (RefC1=:=0-> - deref(Node2) - ; - recorda(refc,m(A,RefC1),_) - ), - format_compression_script1([B|C],Node,Short). - -%%%%%%%%%%%%%%%%%%%%%%%% -% auxiliaries for translation to BDD -%%%%%%%%%%%%%%%%%%%%%%%% - -% prefix the current counter with "L" -get_next_name(Name) :- - retract(c_num(N)), - NN is N+1, - assert(c_num(NN)), - atomic_concat('L',N,Name). - -get_next_var_id(N,Name) :- - retract(v_num(N)), - NN is N+1, - assert(v_num(NN)), - atomic_concat('x',N,Name). - -% create BDD-var as fact id prefixed by x -% learning.yap relies on this format! -% when changing, also adapt test_var_name/1 below -get_var_name(R,S,Number,NameA) :- - get_next_var_id(Number,NameA), - recorda(map,m(R,S,Number,NameA),_). - -% test used by base case of compression mapping to detect single-variable tree -% has to match above naming scheme -test_var_name(T) :- - atomic_concat(x,_,T). diff --git a/packages/cplint/approx/.svn/text-base/utility.pl.svn-base b/packages/cplint/approx/.svn/text-base/utility.pl.svn-base deleted file mode 100644 index 3079235fe..000000000 --- a/packages/cplint/approx/.svn/text-base/utility.pl.svn-base +++ /dev/null @@ -1,367 +0,0 @@ -/*============================================================================== - * LPAD and CP-Logic reasoning suite - * File: parsing.pl - * Parses predicates to load LPADs (main predicate: parse(FileNameNoExt) - * Copyright (c) 2009, Stefano Bragaglia - *============================================================================*/ - -:- dynamic rule/4, def_rule/2. - -% :- source. -% :- yap_flag(single_var_warnings, on). - - - - - -/* BUILTIN PREDICATES - * ------------------ - * This section declares the builtin predicates. - */ -builtin(_A is _B). -builtin(_A > _B). -builtin(_A < _B). -builtin(_A >= _B). -builtin(_A =< _B). -builtin(_A =:= _B). -builtin(_A =\= _B). -builtin(true). -builtin(false). -builtin(_A = _B). -builtin(_A==_B). -builtin(_A\=_B). -builtin(_A\==_B). -builtin(length(_L, _N)). -builtin(member(_El, _L)). -builtin(average(_L, _Av)). -builtin(max_list(_L, _Max)). -builtin(min_list(_L, _Max)). -builtin(nth0(_, _, _)). -builtin(nth(_, _, _)). -builtin(eraseall(_Id)). -builtin(recordz(_Id, _Item, _)). -builtin(recordzifnot(_Id, _Item, _)). - - - -member_eq(Item, [Head|_Tail]) :- - Item==Head, !. - -member_eq(Item, [_Head|Tail]) :- - member_eq(Item, Tail). - - - -not_already_present_with_a_different_head(_HeadId, _RuleId, _Subst, []). - -not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(HeadId1, RuleId, Subst1)|Tail]) :- - not_different(HeadId, HeadId1, Subst, Subst1), !, - not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). - -not_already_present_with_a_different_head(HeadId, RuleId, Subst, [(_HeadId1, RuleId1, _Subst1)|Tail]) :- - RuleId \== RuleId1, - not_already_present_with_a_different_head(HeadId, RuleId, Subst, Tail). - - - -not_different(_HeadId, _HeadId1, Subst, Subst1) :- - Subst \= Subst1, !. - -not_different(HeadId, HeadId1, Subst, Subst1) :- - HeadId \= HeadId1, !, - dif(Subst, Subst1). - -not_different(HeadId, HeadId, Subst, Subst). - - - -get_groundc([], [], [], P, P) :- !. - -get_groundc([H|T], [H|T1], TV, P0, P1) :- - ground(H), !, - H=(N, R, S), - rule_by_num(R, S, _N, Head, _Body), - nth0(N, Head, (_A:P)), - P2 is P0*P, - get_groundc(T, T1, TV, P2, P1). - -get_groundc([H|T], T1, [H|TV], P0, P1) :- - get_groundc(T, T1, TV, P0, P1). - -get_prob([], P, P) :- !. - -get_prob([H|T], P0, P1) :- - H=(N, R, S), - rule_by_num(R, S, _N, Head, _Body), - nth0(N, Head, (_A:P)), - P2 is P0*P, - get_prob(T, P2, P1). - - - - -find_rulec(H, (R, S, N), Body, C, P) :- - rule(H, P, N, R, S, _NH, _Head, Body), - not_already_present_with_a_different_head(N, R, S, C). - - - -/* var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) - * ---------------------------------------------------------------------------------- - * This tail recursive predicate converts a list of couples (Rule, Subst) into a - * list of triples (Index, Count, Probs). - * Rule and Subst are the index of their equivalent rule and substitution. - * Index is a progressive identifier starting from 0. - * Count is the number of head atoms and Probs is the vector of their - * probabilities. - * - * INPUT - * - Couples: list of couples to convert. - * - * OUTPUT - * - Triples: list of equivalent triples. - */ -var2numbers([], _N, []). - -var2numbers([(Rule, Subst)|CoupleTail], Index, [[Index, Heads, Probs]|TripleTail]) :- - find_probs(Rule, Subst, Probs), - length(Probs, Heads), - Next is Index+1, - var2numbers(CoupleTail, Next, TripleTail). - - - -/* build_formula(ListC, Formula, VarIn, VarOut) - * -------------------------------------------- - * This predicate parses a given list of C sets with a given list of variables - * and returns the equivalent formula with its list of variables. - * - * Note: each Formula is expressed in the form: [Term1, ..., TermN], where each - * term is expressed in the form: [Factor1, ..., FactorM], where each - * factor is hence expressed in the form: (Var, Name). - * Finally, Var is the index of the multivalued variable Var, and Value is - * the index of its value. - * - * INPUT - * - ListC: given list of C sets. - * - VarIn: list of variables pertaining to ListC. - * - * OUTPUT - * - Formula: the formula equivalent to ListC. - * - VarOut: list of variables pertaining to Formula. - */ -build_formula([], [], Var, Var, Count, Count). -%% Closing condition: stop if no more terms (current Var is final Var, current Count is final Count) - -build_formula([D|TD], [F|TF], VarIn, VarOut, C0, C1) :- - length(D, NC), - C2 is C0+NC, - reverse(D, D1), - build_term(D1, F, VarIn, Var1), - build_formula(TD, TF, Var1, VarOut, C2, C1). - %% Recursive call: procedd to next terms, building rest of formula and handling vars and count. - -build_formula([], [], Var, Var). - -build_formula([D|TD], [F|TF], VarIn, VarOut) :- - build_term(D, F, VarIn, Var1), - build_formula(TD, TF, Var1, VarOut). - - - -build_term([], [], Var, Var). - -build_term([(_, pruned, _)|TC], TF, VarIn, VarOut) :- !, - build_term(TC, TF, VarIn, VarOut). - -build_term([(N, R, S)|TC], [[NVar, N]|TF], VarIn, VarOut) :- - (nth0_eq(0, NVar, VarIn, (R, S)) -> - Var1=VarIn; - append(VarIn, [(R, S)], Var1), - length(VarIn, NVar)), - build_term(TC, TF, Var1, VarOut). - - - -find_probs(R, S, Probs) :- - rule_by_num(R, S, _N, Head, _Body), - get_probs(Head, Probs). - - - -get_probs(uniform(_A:1/Num, _P, _Number), ListP) :- - Prob is 1/Num, - list_el(Num, Prob, ListP). - -get_probs([], []). - -get_probs([_H:P|T], [P1|T1]) :- - P1 is P, - get_probs(T, T1). - - - -list_el(0, _P, []) :- !. - -list_el(N, P, [P|T]) :- - N1 is N-1, - list_el(N1, P, T). - - - -/* nth0_eq(PosIn, PosOut, List, Elem) - * ---------------------------------- - * This predicate searches for an element that matches with the given one in the - * given list, starting from the given position, and returns its position. - * - * INPUT - * - PosIn: initial position. - * - List: list to parse. - * - Elem: element to match. - * - * OUTPUT - * - PosOut: next position of a matching element. - */ -nth0_eq(N, N, [H|_T], Elem) :- - H==Elem, !. - -nth0_eq(NIn, NOut, [_H|T], Elem) :- - N1 is NIn+1, - nth0_eq(N1, NOut, T, Elem). - - - -list2and([X], X) :- - X\=(_, _), !. - -list2and([H|T], (H, Ta)) :- !, - list2and(T, Ta). - - - -list2or([X], X) :- - X\=;(_, _), !. - -list2or([H|T], (H ; Ta)) :- !, - list2or(T, Ta). - - - -choose_clausesc(_G, C, [], C). - -choose_clausesc(CG0, CIn, [D|T], COut) :- - member((N, R, S), D), - choose_clauses_present(N, R, S, CG0, CIn, COut, T). - -choose_clausesc(G0, CIn, [D|T], COut) :- - member((N, R, S), D), - new_head(N, R, S, N1), - \+ already_present(N1, R, S, CIn), - \+ already_present(N1, R, S, G0), - impose_dif_cons(R, S, CIn), - choose_clausesc(G0, [(N1, R, S)|CIn], T, COut). - - - -choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- - already_present_with_a_different_head_ground(N, R, S, CG0), !, - choose_clausesc(CG0, CIn, T, COut). - -choose_clauses_present(N, R, S, CG0, CIn, COut, T) :- - already_present_with_a_different_head(N, R, S, CIn), - choose_a_head(N, R, S, CIn, C1), - choose_clausesc(CG0, C1, T, COut). - - - -/* new_head(N, R, S, N1) - * --------------------- - * This predicate selects an head for rule R different from N with substitution - * S and returns it in N1. - */ -new_head(N, R, S, N1) :- - rule_by_num(R, S, Numbers, Head, _Body), - Head\=uniform(_, _, _), !, - nth0(N, Numbers, _Elem, Rest), - member(N1, Rest). - -new_head(N, R, S, N1) :- - rule_uniform(_A, R, S, Numbers, 1/Tot, _L, _Number, _Body), - listN(0, Tot, Numbers), - nth0(N, Numbers, _Elem, Rest), - member(N1, Rest). - - - -/* already_present(N, R, S, [(N, R, SH)|_T]) - * ----------------------------------------- - * This predicate checks if a rule R with head N and selection S (or one of its - * generalizations is in C) is already present in C. - */ -already_present(N, R, S, [(N, R, SH)|_T]) :- - S=SH. - -already_present(N, R, S, [_H|T]) :- - already_present(N, R, S, T). - - - -already_present_with_a_different_head(N, R, S, [(NH, R, SH)|_T]) :- - \+ \+ S=SH, NH \= N. - -already_present_with_a_different_head(N, R, S, [_H|T]) :- - already_present_with_a_different_head(N, R, S, T). - -already_present_with_a_different_head_ground(N, R, S, [(NH, R, SH)|_T]) :- - S=SH, NH \= N. - -already_present_with_a_different_head_ground(N, R, S, [_H|T]) :- - already_present_with_a_different_head_ground(N, R, S, T). - - - -impose_dif_cons(_R, _S, []) :- !. - -impose_dif_cons(R, S, [(_NH, R, SH)|T]) :- !, - dif(S, SH), - impose_dif_cons(R, S, T). - -impose_dif_cons(R, S, [_H|T]) :- - impose_dif_cons(R, S, T). - - - -/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) - * -------------------------------------------------------- - * This predicate chooses and returns an head. - * It instantiates a more general rule if it is contained in C with a different - * head. - */ -choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, SH)|T]) :- - S=SH, - dif(N, NH). - -/* choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) - * -------------------------------------------------------------------- - * This predicate chooses and returns an head. - * It instantiates a more general rule if it is contained in C with a different - * head. - * It ensures the same ground clause is not generated again. - */ -choose_a_head(N, R, S, [(NH, R, SH)|T], [(NH, R, S), (NH, R, SH)|T]) :- - \+ \+ S=SH, S\==SH, - dif(N, NH), - dif(S, SH). - -choose_a_head(N, R, S, [H|T], [H|T1]) :- - choose_a_head(N, R, S, T, T1). - - - -listN(N, N, []) :- !. - -listN(NIn, N, [NIn|T]) :- - N1 is NIn+1, - listN(N1, N, T). - - diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops b/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops deleted file mode 100644 index 625e8a0b0..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/all-wcprops +++ /dev/null @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs -END -ProblogBDD.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/ProblogBDD.c -END -simplecudd.h -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/simplecudd.h -END -general.h -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/general.h -END -ProblogBDDclus.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/ProblogBDDclus.c -END -simplecudd.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/simplecudd.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 85 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/Makefile -END -general.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/cplint/!svn/ver/2154/cplint/trunk/cplint_new/approx_src/simplecuddLPADs/general.c -END diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/entries b/packages/cplint/approx/simplecuddLPADs/.svn/entries deleted file mode 100644 index 879bf69da..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/entries +++ /dev/null @@ -1,273 +0,0 @@ -9 - -dir -2205 -https://ds.ing.unife.it/svn/cplint/cplint/trunk/cplint_new/approx_src/simplecuddLPADs -https://ds.ing.unife.it/svn/cplint - - - -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -8b881860-fc2d-0410-9739-81b0d24abadf - - - - - - -0 - -simplecudd.h -file - - - - -2010-03-15T10:08:01.000000Z -07e7f1b7c2ef1d2e345358b8a993d452 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -17432 - -ProblogBDD.c -file - - - - -2010-03-15T10:08:01.000000Z -98293257daff85df3f703c11e3f049a4 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -35511 - -general.h -file - - - - -2010-03-15T10:08:01.000000Z -c4a07810ee4ab51ec579ded4d2467a4b -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -12030 - -ProblogBDDclus.c -file - - - - -2010-03-15T10:08:01.000000Z -9c3bee903af5a2c4e26d3c413d3ef4f5 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -36201 - -simplecudd.c -file - - - - -2010-03-15T10:08:01.000000Z -d92d01ea87ba9caa86311df989c8f6a2 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -67867 - -Makefile -file - - - - -2010-03-15T10:08:01.000000Z -7b252aa4540f97f9955e69cd66cf022e -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -1335 - -general.c -file - - - - -2010-03-15T10:08:01.000000Z -581112590eceb12912be10381846d207 -2010-03-15T10:14:10.890703Z -2154 -friguzzi - - - - - - - - - - - - - - - - - - - - - -13543 - diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/format b/packages/cplint/approx/simplecuddLPADs/.svn/format deleted file mode 100644 index ec635144f..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/format +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base deleted file mode 100644 index f8afe98ed..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/Makefile.svn-base +++ /dev/null @@ -1,55 +0,0 @@ -# -# default base directory for YAP installation -# (EROOT for architecture-dependent files) -# -prefix = /home/rzf/usr/local -ROOTDIR = $(prefix) -EROOTDIR = ${prefix} -# -# where the binary should be -# -BINDIR = $(EROOTDIR)/bin -# -# where YAP should look for libraries -# -LIBDIR=$(EROOTDIR)/lib/Yap -DESTDIR=$(prefix)/share/Yap -# -# -CC=gcc -# -# -# You shouldn't need to change what follows. -# -INSTALL=/usr/bin/install -c -INSTALL_DATA=${INSTALL} -m 644 -INSTALL_PROGRAM=${INSTALL} -SHELL=/bin/sh -RANLIB=ranlib -SHLIB_CFLAGS=-shared -fPIC -SHLIB_SUFFIX=.so -CWD=$(PWD) -# - -CUDD = cudd-2.4.1 -DYNAMIC = -CFLAGS = -DBP_FREE -O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes -I/home/rzf/usr/local/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -INCLUDE = -LINKFLAGS = -L/home/rzf/usr/local/lib -L/lib/ -lm -lglu -LINKLIBS = -lcu -lm -lglu -lglib-2.0 - -default: LPADBDD - -LPADBDD: ProblogBDD.o simplecudd.o general.o - @echo Making ProblogBDD... - @echo Copyright T. Mantadelis, A. Kimmig, B. Gutmann and Katholieke Universiteit Leuven 2008 - $(CC) $(LINKLIBS) $(LINKFLAGS) -I/home/rzf/usr/local/include ProblogBDD.o simplecudd.o general.o $(LINKLIBS) $(LINKFLAGS) -o LPADBDD - -%.o : $(srcdir)/%.c - $(CC) $(CFLAGS) $(INCLUDE) $(DYNAMIC) -c $< - -clean: - rm -f *.o LPADBDD - -install: default - $(INSTALL_PROGRAM) LPADBDD $(DESTDIR) diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base deleted file mode 100644 index 269ae533d..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDD.c.svn-base +++ /dev/null @@ -1,871 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * -* and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * -* File: ProblogBDD.c * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include "simplecudd.h" -#include -#include - -typedef struct _parameters { - int loadfile; - int savedfile; - int exportfile; - int inputfile; - int debug; - int errorcnt; - int *error; - int method; - int queryid; - int timeout; - double sigmoid_slope; - int online; - int maxbufsize; - char *ppid; -} parameters; - -typedef struct _gradientpair { - double probability; - double gradient; -} gradientpair; - -typedef struct _extmanager { - DdManager *manager; - DdNode *t, *f; - hisqueue *his; - namedvars varmap; -} extmanager; - - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); -double Prob(extmanager MyManager, DdNode *node, int comp); -int correctPosition(int index,variable v,int posBVar); -double ret_prob(extmanager MyManager, DdNode * bdd); - - - -int argtype(const char *arg); -void printhelp(int argc, char **arg); -parameters loadparam(int argc, char **arg); -parameters params; - -void handler(int num); -void pidhandler(int num); -void termhandler(int num); - -double sigmoid(double x, double slope); -void myexpand(extmanager MyManager, DdNode *Current); -double CalcProbability(extmanager MyManager, DdNode *Current); -double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); -int patterncalculated(char *pattern, extmanager MyManager, int loc); -char * extractpattern(char *thestr); - -int main(int argc, char **arg) { - clock_t start, endc, endt; - double elapsedc,elapsedt; - - extmanager MyManager; - DdNode *bdd; - bddfileheader fileheader; - int i, ivarcnt, code; - gradientpair tvalue; - double probability = -1.0; - char *varpattern; - varpattern = NULL; - code = -1; - params = loadparam(argc, arg); - if (params.errorcnt > 0) { - printhelp(argc, arg); - for (i = 0; i < params.errorcnt; i++) { - fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); - } - return -1; - } - - if (params.online == 0 && params.loadfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: you must specify a loading file.\n"); - return -1; - } - - if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { - printhelp(argc, arg); - fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); - return -1; - } - - if (params.debug) DEBUGON; - RAPIDLOADON; - SETMAXBUFSIZE(params.maxbufsize); - - signal(SIGINT, termhandler); - if (params.ppid != NULL) { - signal(SIGALRM, pidhandler); - alarm(5); - } else { - signal(SIGALRM, handler); - alarm(params.timeout); - } - if (params.online) { - MyManager.manager = simpleBDDinit(0); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(1, 0); - bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); - ivarcnt = GetVarCount(MyManager.manager); - } else { - fileheader = ReadFileHeader(arg[params.loadfile]); - switch(fileheader.filetype) { - case BDDFILE_SCRIPT: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); - if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; - start = clock(); - bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); - endc=clock(); - elapsedc = ((double) (endc - start)) / CLOCKS_PER_SEC; - printf("elapsed_construction(%lf).\n",elapsedc); - ivarcnt = fileheader.varcnt; - break; - case BDDFILE_NODEDUMP: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); - bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); - ivarcnt = fileheader.varcnt; - break; - default: - fprintf(stderr, "Error: not a valid file format to load.\n"); - return -1; - break; - } - } - alarm(0); - - // problem specifics - - if (bdd != NULL) { - ivarcnt = RepairVarcnt(&MyManager.varmap); - code = 0; - /* - if (params.inputfile != -1) { - if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; - if (!all_loaded(MyManager.varmap, 1)) return -1; - }*/ - MyManager.his = InitHistory(ivarcnt); - if (params.method != 0) { - switch(arg[params.method][0]) { - case 'g': - for (i = 0; i < MyManager.varmap.varcnt; i++) { - if (MyManager.varmap.vars[i] != NULL) { - varpattern = extractpattern(MyManager.varmap.vars[i]); - if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { - tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); - probability = tvalue.probability; - double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; - if (varpattern == NULL) { - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); - } else { - varpattern[strlen(varpattern) - 2] = '\0'; - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); - } - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - } - if (varpattern != NULL) free(varpattern); - } else { - fprintf(stderr, "Error: no variable name given for parameter.\n"); - } - } - if (probability < 0.0) { - // no nodes, so we have to calculate probability ourself - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - } - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'l': - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'p': - printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); - break; - case 'o': - onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); - break; - default: - myexpand(MyManager, bdd); - break; - } - } else { - start=clock(); - // simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); - printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); - endt=clock(); - elapsedt = ((double) (endt - start)) / CLOCKS_PER_SEC; - printf("elapsed_traversing(%lf).\n",elapsedt); -// myexpand(MyManager, bdd); - } - if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); - if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - free(MyManager.his); - } - if (MyManager.manager != NULL) { - KillBDD(MyManager.manager); -exit(code); - free(MyManager.varmap.dvalue); - free(MyManager.varmap.ivalue); - free(MyManager.varmap.dynvalue); - for (i = 0; i < MyManager.varmap.varcnt; i++) - { - free(MyManager.varmap.vars[i]); - free(MyManager.varmap.mvars[i].probabilities); - free(MyManager.varmap.mvars[i].booleanVars); - } - free(MyManager.varmap.vars); - free(MyManager.varmap.mvars); - free(MyManager.varmap.bVar2mVar); - } - if (params.error != NULL) free(params.error); - - return code; - -} - -/* Shell Parameters handling */ - -int argtype(const char *arg) { - if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; - if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; - if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; - if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; - if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; - if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; - if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; - if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; - if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; - if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; - if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; - if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; - if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; - return -1; -} - -void printhelp(int argc, char **arg) { - fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); - fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); - fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); - fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); - fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); - fprintf(stderr, "Optional parameters:\n"); - fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); - fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); - fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); - fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); - fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); - fprintf(stderr, "Extra parameters:\n"); - fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); - fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); - fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); - fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); - fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); - fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); -} - -parameters loadparam(int argc, char **arg) { - int i; - parameters params; - params.loadfile = -1; - params.savedfile = -1; - params.exportfile = -1; - params.method = 0; - params.inputfile = -1; - params.debug = 0; - params.errorcnt = 0; - params.queryid = 0; - params.timeout = 0; - params.sigmoid_slope = 1.0; - params.online = 0; - params.maxbufsize = 0; - params.ppid = NULL; - params.error = (int *) malloc(argc * sizeof(int)); - for (i = 1; i < argc; i++) { - switch(argtype(arg[i])) { - case 0: - if (argc > i + 1) { - i++; - params.loadfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 2: - if (argc > i + 1) { - i++; - params.exportfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 3: - if (argc > i + 1) { - i++; - params.method = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 4: - if (argc > i + 1) { - i++; - params.inputfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 5: - printhelp(argc, arg); - break; - case 6: - params.debug = 1; - break; - case 7: - if (argc > i + 1) { - i++; - params.queryid = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 8: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.timeout = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 9: - if (argc > i + 1) { - i++; - params.savedfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 10: - if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { - i++; - params.sigmoid_slope = atof(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 11: - params.online = 1; - break; - case 12: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.maxbufsize = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 13: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); - strcpy(params.ppid, arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - default: - params.error[params.errorcnt] = i; - params.errorcnt++; - break; - } - } - return params; -} - -/* Error Handlers */ - -void handler(int num) { - fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); - exit(-1); -} - -void pidhandler(int num) { - char *s; - if (params.timeout > 0) { - params.timeout -= 5; - if (params.timeout <= 0) { - fprintf(stderr, "Error: Timeout exceeded.\n"); - exit(-1); - } - } - s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); - strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); - if (system(s) != 0) exit(4); - signal(SIGALRM, pidhandler); - alarm(5); - free(s); -} - -void termhandler(int num) { - exit(3); -} - -/* General Functions */ - -double sigmoid(double x, double slope) { - return 1 / (1 + exp(-x * slope)); -} - -/* Debugging traverse function */ - -void myexpand(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - printf("%s\n", curnode); - if ((Current != MyManager.t) && (Current != MyManager.f) && - ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - printf("l(%s)->", curnode); - myexpand(MyManager, l); - printf("h(%s)->", curnode); - myexpand(MyManager, h); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); - } -} - -/* Angelikas Algorithm */ - -double CalcProbability(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - double lvalue, hvalue, tvalue; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) return 1.0; - if (Current == MyManager.f) return 0.0; - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcProbability(MyManager, l); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcProbability(MyManager, h); - tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; - tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); - return tvalue; -} - -/* Bernds Algorithm */ - -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - gradientpair lvalue, hvalue, tvalue; - double this_probability; - double *gradient; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) { - tvalue.probability = 1.0; - tvalue.gradient = 0.0; - return tvalue; - } - if (Current == MyManager.f) { - tvalue.probability = 0.0; - tvalue.gradient = 0.0; - return tvalue; - } - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { - tvalue.probability = Found->dvalue; - tvalue.gradient = *((double *) Found->dynvalue); - return tvalue; - } - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); - this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); - tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; - tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; - if ((GetIndex(Current) == TargetVar) || - ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { - tvalue.gradient += hvalue.probability - lvalue.probability; - } - gradient = (double *) malloc(sizeof(double)); - *gradient = tvalue.gradient; - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); - return tvalue; -} - -char * extractpattern(char *thestr) { - char *p; - int i = 0, sl = strlen(thestr); - while((thestr[i] != '_') && (i < sl)) i++; - if (i == sl) return NULL; - i++; - p = (char *) malloc(sizeof(char) * (i + 2)); - strncpy(p, thestr, i); - p[i] = '*'; - p[i + 1] = '\0'; - return p; -} - -int patterncalculated(char *pattern, extmanager MyManager, int loc) { - int i; - if (pattern == NULL) return 0; - for (i = loc - 1; i > -1; i--) - if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; - return 0; -} - -double Prob(extmanager MyManager, DdNode *node, int comp) -/* compute the probability of the expression rooted at node -nodes is used to store nodes for which the probability has alread been computed -so that it is not recomputed - */ -{ - int mVarIndex,nBit,index; - variable v; - hisnode *Found; - double res; - double value; - - - //printf("Prob node %d\n",node); - //index=Cudd_NodeReadIndex(node); - //printf("Prob INdex %d\n",index); - if (Cudd_IsConstant(node)) - { - value=Cudd_V(node);//node->type.value; - //printf("Value %e comp %d\n",value,comp); - if (comp)//Cudd_IsComplement(node)) - //return (1.0-value); - //if (value>0) - { -// printf("return 0"); - return 0.0; - } - else - { -// printf("return 1"); - return 1.0; - } -/*else - if (value>0) - return 1.0; - else - return 0.0; -*/ //return value; - } - else -{ - Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); - - if (Found!=NULL) - { - //printf("value found %e\n",Found->dvalue); - return Found->dvalue; - } - else - { - index=Cudd_NodeReadIndex(node); - //printf("node absent %d comp %d\n",node,comp); - //mVarIndex=array_fetch(int,bVar2mVar,index); - mVarIndex=MyManager.varmap.bVar2mVar[index]; - //v=array_fetch(variable,vars,mVarIndex); - v=MyManager.varmap.mvars[mVarIndex]; - nBit=v.nBit; -// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); - //scanf("%d",&r); - res=ProbBool(MyManager,node,0,nBit,0,v,comp); - //printf("New val %e\n",res); - AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); - return res; - } -} -} - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) -/* explores a group of binary variables making up the multivalued variable v */ -{ - DdNode *T,*F; - double p,res; - double * probs; - int index; -// printf("ProbBool nBit %d\n",nBit); - //scanf("%d",&r); - probs=v.probabilities; - if (nBit==0) - { - //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); -// printf("bits %d v.nbit %d\n",bits,v.nBit); - if (bits>=v.nVal) - //if (comp) - { - //printf("bits>=v.nbit return 0\n"); - return 0.0; - } - //else - //{printf("return 0\n"); - //return 1.0;}} - else - { - // printf("Val %d\n",bits); - - //p=array_fetch(double,probs,bits); - p=probs[bits]; - //printf("prob %e\n",p); - res=p*Prob(MyManager,node,comp); - //printf("prob %e\n",p); - //printf("bottom %e\n",res); - return res; - } - } - else - { - //if (correctPosition(node->index,v,node,posBVar)) - index=Cudd_NodeReadIndex(node); - //printf("index %d\n",Cudd_NodeReadIndex(node)); - if (correctPosition(index,v,posBVar)) - { - //printf("node %d\n",node); - T = Cudd_T(node);//node->type.kids.T; - F = Cudd_E(node);//node->type.kids.E; - bits=bits<<1; - //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); - res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); - //printf("comp %d ",comp); - comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); - //printf("comp %d \n",comp); -res=res+ - ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); - //printf("res 2 %e\n",res); - return res; - } - else - { - //printf("absent var\n"); - bits=bits<<1; - // printf("Var =1\n"); - res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res 1 %e\n",res); -//printf("var =0\n"); - res=res+ - ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); - // printf("res 2 %e\n",res); -return res; - } - } -} - -int correctPosition(int index,variable v,int posBVar) -/* returns 1 is the boolean variable with index posBVar is in the correct position -currently explored by ProbBool */ -{ - int bvar; -//printf("posbvar %d\n",posBVar); -//printf("length %d\n",array_n(v.booleanVars)); - //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); - bvar=v.booleanVars[posBVar]; - - // return var->index==index; -return(bvar==index); -} - -double ret_prob(extmanager MyManager, DdNode * bdd) -{ - double prob; - /* dividend is a global variable used by my_hash - it is equal to an unsigned int with binary representation 11..1 */ - prob=Prob(MyManager,bdd,Cudd_IsComplement(bdd)); - - return prob; - -} diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base deleted file mode 100644 index a799895bc..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/ProblogBDDclus.c.svn-base +++ /dev/null @@ -1,895 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * -* and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * -* File: ProblogBDD.c * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include "simplecudd.h" -#include - -typedef struct _parameters { - int loadfile; - int savedfile; - int exportfile; - int inputfile; - int debug; - int errorcnt; - int *error; - int method; - int queryid; - int timeout; - double sigmoid_slope; - int online; - int maxbufsize; - char *ppid; -} parameters; - -typedef struct _gradientpair { - double probability; - double gradient; -} gradientpair; - -typedef struct _extmanager { - DdManager *manager; - DdNode *t, *f; - hisqueue *his; - namedvars varmap; -} extmanager; - -GHashTable * nodes; /* hash table that associates nodes with their probability if already - computed, it is defined in glib */ -unsigned long dividend; - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); -double Prob(extmanager MyManager, DdNode *node, int comp); -int correctPosition(int index,variable v, DdNode * node,int posBVar); -gint my_equal(gconstpointer v,gconstpointer v2); -guint my_hash(gconstpointer key); -void dealloc(gpointer key,gpointer value,gpointer user_data); -double ret_prob(extmanager MyManager, DdNode * bdd); - - - -int argtype(const char *arg); -void printhelp(int argc, char **arg); -parameters loadparam(int argc, char **arg); -parameters params; - -void handler(int num); -void pidhandler(int num); -void termhandler(int num); - -double sigmoid(double x, double slope); -void myexpand(extmanager MyManager, DdNode *Current); -double CalcProbability(extmanager MyManager, DdNode *Current); -double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); -int patterncalculated(char *pattern, extmanager MyManager, int loc); -char * extractpattern(char *thestr); - -int main(int argc, char **arg) { - extmanager MyManager; - DdNode *bdd; - bddfileheader fileheader; - int i, ivarcnt, code; - gradientpair tvalue; - double probability = -1.0; - char *varpattern; - varpattern = NULL; - code = -1; - params = loadparam(argc, arg); - if (params.errorcnt > 0) { - printhelp(argc, arg); - for (i = 0; i < params.errorcnt; i++) { - fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); - } - return -1; - } - - if (params.online == 0 && params.loadfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: you must specify a loading file.\n"); - return -1; - } - - if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { - printhelp(argc, arg); - fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); - return -1; - } - - if (params.debug) DEBUGON; - RAPIDLOADON; - SETMAXBUFSIZE(params.maxbufsize); - - signal(SIGINT, termhandler); - if (params.ppid != NULL) { - signal(SIGALRM, pidhandler); - alarm(5); - } else { - signal(SIGALRM, handler); - alarm(params.timeout); - } - if (params.online) { - MyManager.manager = simpleBDDinit(0); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(1, 0); - bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); - ivarcnt = GetVarCount(MyManager.manager); - } else { - fileheader = ReadFileHeader(arg[params.loadfile]); - switch(fileheader.filetype) { - case BDDFILE_SCRIPT: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); - if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; - bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); - ivarcnt = fileheader.varcnt; - break; - case BDDFILE_NODEDUMP: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); - bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); - ivarcnt = fileheader.varcnt; - break; - default: - fprintf(stderr, "Error: not a valid file format to load.\n"); - return -1; - break; - } - } - alarm(0); - - // problem specifics - - if (bdd != NULL) { - ivarcnt = RepairVarcnt(&MyManager.varmap); - code = 0; - /* - if (params.inputfile != -1) { - if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; - if (!all_loaded(MyManager.varmap, 1)) return -1; - }*/ - MyManager.his = InitHistory(ivarcnt); - if (params.method != 0) { - switch(arg[params.method][0]) { - case 'g': - for (i = 0; i < MyManager.varmap.varcnt; i++) { - if (MyManager.varmap.vars[i] != NULL) { - varpattern = extractpattern(MyManager.varmap.vars[i]); - if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { - tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); - probability = tvalue.probability; - double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; - if (varpattern == NULL) { - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); - } else { - varpattern[strlen(varpattern) - 2] = '\0'; - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); - } - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - } - if (varpattern != NULL) free(varpattern); - } else { - fprintf(stderr, "Error: no variable name given for parameter.\n"); - } - } - if (probability < 0.0) { - // no nodes, so we have to calculate probability ourself - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - } - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'l': - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'p': - printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); - break; - case 'o': - onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); - break; - default: - myexpand(MyManager, bdd); - break; - } - } else { - //simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); - printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); -// myexpand(MyManager, bdd); - } - if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); - if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - free(MyManager.his); - } - if (MyManager.manager != NULL) { - KillBDD(MyManager.manager); - free(MyManager.varmap.dvalue); - free(MyManager.varmap.ivalue); - free(MyManager.varmap.dynvalue); - for (i = 0; i < MyManager.varmap.varcnt; i++) - { - free(MyManager.varmap.vars[i]); - free(MyManager.varmap.mvars[i].probabilities); - free(MyManager.varmap.mvars[i].booleanVars); - } - free(MyManager.varmap.vars); - free(MyManager.varmap.mvars); - free(MyManager.varmap.bVar2mVar); - } - if (params.error != NULL) free(params.error); - - return code; - -} - -/* Shell Parameters handling */ - -int argtype(const char *arg) { - if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; - if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; - if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; - if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; - if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; - if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; - if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; - if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; - if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; - if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; - if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; - if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; - if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; - return -1; -} - -void printhelp(int argc, char **arg) { - fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); - fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); - fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); - fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); - fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); - fprintf(stderr, "Optional parameters:\n"); - fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); - fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); - fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); - fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); - fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); - fprintf(stderr, "Extra parameters:\n"); - fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); - fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); - fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); - fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); - fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); - fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); -} - -parameters loadparam(int argc, char **arg) { - int i; - parameters params; - params.loadfile = -1; - params.savedfile = -1; - params.exportfile = -1; - params.method = 0; - params.inputfile = -1; - params.debug = 0; - params.errorcnt = 0; - params.queryid = 0; - params.timeout = 0; - params.sigmoid_slope = 1.0; - params.online = 0; - params.maxbufsize = 0; - params.ppid = NULL; - params.error = (int *) malloc(argc * sizeof(int)); - for (i = 1; i < argc; i++) { - switch(argtype(arg[i])) { - case 0: - if (argc > i + 1) { - i++; - params.loadfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 2: - if (argc > i + 1) { - i++; - params.exportfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 3: - if (argc > i + 1) { - i++; - params.method = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 4: - if (argc > i + 1) { - i++; - params.inputfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 5: - printhelp(argc, arg); - break; - case 6: - params.debug = 1; - break; - case 7: - if (argc > i + 1) { - i++; - params.queryid = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 8: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.timeout = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 9: - if (argc > i + 1) { - i++; - params.savedfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 10: - if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { - i++; - params.sigmoid_slope = atof(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 11: - params.online = 1; - break; - case 12: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.maxbufsize = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 13: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); - strcpy(params.ppid, arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - default: - params.error[params.errorcnt] = i; - params.errorcnt++; - break; - } - } - return params; -} - -/* Error Handlers */ - -void handler(int num) { - fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); - exit(-1); -} - -void pidhandler(int num) { - char *s; - if (params.timeout > 0) { - params.timeout -= 5; - if (params.timeout <= 0) { - fprintf(stderr, "Error: Timeout exceeded.\n"); - exit(-1); - } - } - s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); - strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); - if (system(s) != 0) exit(4); - signal(SIGALRM, pidhandler); - alarm(5); - free(s); -} - -void termhandler(int num) { - exit(3); -} - -/* General Functions */ - -double sigmoid(double x, double slope) { - return 1 / (1 + exp(-x * slope)); -} - -/* Debugging traverse function */ - -void myexpand(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - printf("%s\n", curnode); - if ((Current != MyManager.t) && (Current != MyManager.f) && - ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - printf("l(%s)->", curnode); - myexpand(MyManager, l); - printf("h(%s)->", curnode); - myexpand(MyManager, h); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); - } -} - -/* Angelikas Algorithm */ - -double CalcProbability(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - double lvalue, hvalue, tvalue; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) return 1.0; - if (Current == MyManager.f) return 0.0; - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcProbability(MyManager, l); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcProbability(MyManager, h); - tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; - tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); - return tvalue; -} - -/* Bernds Algorithm */ - -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - gradientpair lvalue, hvalue, tvalue; - double this_probability; - double *gradient; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) { - tvalue.probability = 1.0; - tvalue.gradient = 0.0; - return tvalue; - } - if (Current == MyManager.f) { - tvalue.probability = 0.0; - tvalue.gradient = 0.0; - return tvalue; - } - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { - tvalue.probability = Found->dvalue; - tvalue.gradient = *((double *) Found->dynvalue); - return tvalue; - } - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); - this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); - tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; - tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; - if ((GetIndex(Current) == TargetVar) || - ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { - tvalue.gradient += hvalue.probability - lvalue.probability; - } - gradient = (double *) malloc(sizeof(double)); - *gradient = tvalue.gradient; - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); - return tvalue; -} - -char * extractpattern(char *thestr) { - char *p; - int i = 0, sl = strlen(thestr); - while((thestr[i] != '_') && (i < sl)) i++; - if (i == sl) return NULL; - i++; - p = (char *) malloc(sizeof(char) * (i + 2)); - strncpy(p, thestr, i); - p[i] = '*'; - p[i + 1] = '\0'; - return p; -} - -int patterncalculated(char *pattern, extmanager MyManager, int loc) { - int i; - if (pattern == NULL) return 0; - for (i = loc - 1; i > -1; i--) - if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; - return 0; -} - -double Prob(extmanager MyManager, DdNode *node, int comp) -/* compute the probability of the expression rooted at node -nodes is used to store nodes for which the probability has alread been computed -so that it is not recomputed - */ -{ - int index,mVarIndex,nBit; - variable v; - hisnode *Found; - double res; - double value; - - - //index=node->index; - //printf("Prob node %d\n",node); - //index=Cudd_NodeReadIndex(node); - //printf("Prob INdex %d\n",index); - if (Cudd_IsConstant(node)) - { - value=Cudd_V(node);//node->type.value; - //printf("Value %e comp %d\n",value,comp); - if (comp)//Cudd_IsComplement(node)) - //return (1.0-value); - //if (value>0) - { -// printf("return 0"); - return 0.0; - } - else - { -// printf("return 1"); - return 1.0; - } -/*else - if (value>0) - return 1.0; - else - return 0.0; -*/ //return value; - } - else -{ - Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); - - if (Found!=NULL) - { - //printf("value found %e\n",*value_p); - return Found->dvalue; - } - else - { - index=Cudd_NodeReadIndex(node); - //printf("node absent %d comp %d\n",node,comp); - //mVarIndex=array_fetch(int,bVar2mVar,index); - mVarIndex=MyManager.varmap.bVar2mVar[index]; - //v=array_fetch(variable,vars,mVarIndex); - v=MyManager.varmap.mvars[mVarIndex]; - nBit=v.nBit; -// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); - //scanf("%d",&r); - res=ProbBool(MyManager,node,0,nBit,0,v,comp); - //printf("New val %e\n",res); - AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); - return res; - } -} -} - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) -/* explores a group of binary variables making up the multivalued variable v */ -{ - DdNode *T,*F; - double p,res; - double * probs; - int index; -// printf("ProbBool nBit %d\n",nBit); - //scanf("%d",&r); - probs=v.probabilities; - if (nBit==0) - { - //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); -// printf("bits %d v.nbit %d\n",bits,v.nBit); - if (bits>=v.nVal) - //if (comp) - { - //printf("bits>=v.nbit return 0\n"); - return 0.0; - } - //else - //{printf("return 0\n"); - //return 1.0;}} - else - { - // printf("Val %d\n",bits); - - //p=array_fetch(double,probs,bits); - p=probs[bits]; - //printf("prob %e\n",p); - res=p*Prob(MyManager,node,comp); - //printf("prob %e\n",p); - //printf("bottom %e\n",res); - return res; - } - } - else - { - //if (correctPosition(node->index,v,node,posBVar)) - index=Cudd_NodeReadIndex(node); - //printf("index %d\n",Cudd_NodeReadIndex(node)); - if (correctPosition(index,v,node,posBVar)) - { - //printf("node %d\n",node); - T = Cudd_T(node);//node->type.kids.T; - F = Cudd_E(node);//node->type.kids.E; - bits=bits<<1; - //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); - res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); - //printf("comp %d ",comp); - comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); - //printf("comp %d \n",comp); -res=res+ - ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); - //printf("res 2 %e\n",res); - return res; - } - else - { - //printf("absent var\n"); - bits=bits<<1; - // printf("Var =1\n"); - res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res 1 %e\n",res); -//printf("var =0\n"); - res=res+ - ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); - // printf("res 2 %e\n",res); -return res; - } - } -} - -int correctPosition(int index,variable v, DdNode * node,int posBVar) -/* returns 1 is the boolean variable with index posBVar is in the correct position -currently explored by ProbBool */ -{ - DdNode * bvar; -//printf("posbvar %d\n",posBVar); -//printf("length %d\n",array_n(v.booleanVars)); - //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); - bvar=v.booleanVars[posBVar]; - - // return var->index==index; -return(Cudd_NodeReadIndex(bvar)==index); -} - -gint my_equal(gconstpointer v,gconstpointer v2) -/* function used by GHashTable to compare two keys */ -{ - DdNode *a,*b; - a=*(DdNode **)v; - b=*(DdNode **)v2; - return (a==b); -} -guint my_hash(gconstpointer key) -/* function used by GHashTable to hash a key */ -{ - unsigned int h; - h=(unsigned int)((unsigned long) *((DdNode **)key) % dividend); - return h; -} -void dealloc(gpointer key,gpointer value,gpointer user_data) -{ - free(key); - free(value); -} -double ret_prob(extmanager MyManager, DdNode * bdd) -{ - int intBits,j; - double prob; - nodes=g_hash_table_new(my_hash,my_equal); - intBits=sizeof(unsigned int)*8; - /* dividend is a global variable used by my_hash - it is equal to an unsigned int with binary representation 11..1 */ - dividend=1; - for(j=1;j= sl) return 0; - if ((thestr[j] == pattern[i]) && patternmatch(pattern + i, thestr + j)) return 1; - } while(1); - } else { - j++; - if (j >= sl) return 0; - if (pattern[i] != thestr[j]) return 0; - } - } - return (pl == sl); -} diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base deleted file mode 100644 index 4441ed623..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/general.h.svn-base +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis * -* File: general.h * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include -#include -#include - -#define IsNumberDigit(c) ('0' <= c && c <= '9') -#define IsSignDigit(c) (c == '+' || c == '-') -#define isOperator(x) (x == '+' || x == '*' || x == '#' || x == '=') -#define freadline(fd) freadstr(fd, "\n"); - -int IsRealNumber(char *c); -int IsPosNumber(const char *c); -int IsNumber(const char *c); -char * freadstr(FILE *fd, const char *separators); -int CharIn(const char c, const char *in); -int patternmatch(char *pattern, char *thestr); diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base deleted file mode 100644 index e361aeb91..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.c.svn-base +++ /dev/null @@ -1,1747 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis * -* File: simplecudd.c * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include "simplecudd.h" - -/* BDD manager initialization */ - -int _debug = 0; -int _RapidLoad = 0; -int _maxbufsize = 0; -int boolVars=0; - -DdManager* simpleBDDinit(int varcnt) { - DdManager *temp; - temp = Cudd_Init(varcnt, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0); - Cudd_AutodynEnable(temp, CUDD_REORDER_GROUP_SIFT); - Cudd_SetMaxCacheHard(temp, 1024*1024*1024); - Cudd_SetLooseUpTo(temp, 1024*1024*512); - if (_debug) - Cudd_EnableReorderingReporting(temp); - return temp; -} - -/* BDD tree travesrsing */ - -DdNode* HighNodeOf(DdManager *manager, DdNode *node) { - DdNode *tmp; - if (IsHigh(manager, node)) return HIGH(manager); - if (IsLow(manager, node)) return LOW(manager); - tmp = Cudd_Regular(node); - if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.T); - return tmp->type.kids.T; -} - -DdNode* LowNodeOf(DdManager *manager, DdNode *node) { - DdNode *tmp; - if (IsHigh(manager, node)) return HIGH(manager); - if (IsLow(manager, node)) return LOW(manager); - tmp = Cudd_Regular(node); - if (Cudd_IsComplement(node)) return NOT(tmp->type.kids.E); - return tmp->type.kids.E; -} - -/* BDD tree generation */ - -DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddAnd(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddNand(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddOr(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddNor(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddXor(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2) { - DdNode *tmp; - tmp = Cudd_bddXnor(manager, bdd1, bdd2); - Cudd_Ref(tmp); - Cudd_RecursiveDeref(manager, bdd2); - return tmp; -} - -/* file manipulation */ - -bddfileheader ReadFileHeader(char *filename) { - bddfileheader temp; - char *header; - temp.inputfile = NULL; - temp.version = 0; - temp.varcnt = 0; - temp.varstart = 0; - temp.intercnt = 0; - temp.filetype = BDDFILE_OTHER; - if ((temp.inputfile = fopen(filename, "r")) == NULL) { - perror(filename); - temp.filetype = BDDFILE_ERROR; - return temp; - } - // Read file header - if (!feof(temp.inputfile)) { - header = freadline(temp.inputfile); - temp.version = CheckFileVersion(header); - if (temp.version > -1) temp.filetype = (strlen(header) == 5) * BDDFILE_SCRIPT + (strlen(header) == 7) * BDDFILE_NODEDUMP; - free(header); - switch (temp.filetype) { - case BDDFILE_SCRIPT: - switch (temp.version) { - case 1: - fscanf(temp.inputfile, "%i\n", &temp.varcnt); - fscanf(temp.inputfile, "%i\n", &temp.bvarcnt); - fscanf(temp.inputfile, "%i\n", &temp.varstart); - fscanf(temp.inputfile, "%i\n", &temp.intercnt); - break; - default: - fclose(temp.inputfile); - temp.inputfile = NULL; - break; - } - break; - case BDDFILE_NODEDUMP: - switch (temp.version) { - case 1: - fscanf(temp.inputfile, "%i\n", &temp.varcnt); - fscanf(temp.inputfile, "%i\n", &temp.varstart); - break; - default: - fclose(temp.inputfile); - temp.inputfile = NULL; - break; - } - break; - case BDDFILE_OTHER: - fclose(temp.inputfile); - temp.inputfile = NULL; - break; - default: - fclose(temp.inputfile); - temp.inputfile = NULL; - break; - } - } - return temp; -} - -int CheckFileVersion(const char *version) { - if (strlen(version) < 5) return -1; - if (strlen(version) == 5 && version[0] == '@' && version[1] == 'B' && version[2] == 'D' && version[3] == 'D') return atoi(version + 4); - if (strlen(version) == 7 && version[0] == '@' && version[1] == 'N' && version[2] == 'O' && version[3] == 'D' - && version[4] == 'E' && version[5] == 'S') return atoi(version + 6); - return -1; -} - -int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename) { - DdNode *f[1]; - int ret; - FILE *fd; - f[0] = Cudd_BddToAdd(manager, bdd); - fd = fopen(filename, "w"); - if (fd == NULL) { - perror(filename); - return -1; - } - ret = Cudd_DumpDot(manager, 1, f, NULL, NULL, fd); - fclose(fd); - return ret; -} - -int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { - DdNode *f[1]; - int ret; - FILE *fd; - f[0] = Cudd_BddToAdd(manager, bdd); - fd = fopen(filename, "w"); - if (fd == NULL) { - perror(filename); - return -1; - } - ret = Cudd_DumpDot(manager, 1, f, varmap.vars, NULL, fd); - fclose(fd); - return ret; -} - -int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename) { - hisqueue *Nodes; - FILE *outputfile; - int i; - if ((outputfile = fopen(filename, "w")) == NULL) { - perror(filename); - return -1; - } - fprintf(outputfile, "%s\n%i\n%i\n", "@NODES1", varmap.varcnt, varmap.varstart); - Nodes = InitHistory(varmap.varcnt); - for (i = 0; i < varmap.varcnt; i++) - fprintf(outputfile, "%s\t%i\n", varmap.vars[i], Cudd_ReadPerm(manager, i)); - if (bdd == HIGH(manager)) fprintf(outputfile, "TRUE\t0\tTRUE\t0\tTRUE\t0\n"); - else if (bdd == LOW(manager)) fprintf(outputfile, "FALSE\t0\tFALSE\t0\tFALSE\t0\n"); - else SaveExpand(manager, varmap, Nodes, bdd, outputfile); - ReInitHistory(Nodes, varmap.varcnt); - free(Nodes); - fclose(outputfile); - return 0; -} - -void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - int inode; - if (Current != HIGH(manager) && Current != LOW(manager)) { - if ((Found = GetNode(Nodes, varmap.varstart, Current)) == NULL) { - AddNode(Nodes, varmap.varstart, Current, 0.0, 0, NULL); - Found = GetNode(Nodes, varmap.varstart, Current); - } - if (!(Found->ivalue)) { - Found->ivalue = 1; - curnode = GetNodeVarNameDisp(manager, varmap, Current); - inode = GetNodeIndex(Nodes, varmap.varstart, Current); - fprintf(outputfile, "%s\t%i\t", curnode, inode); - h = HighNodeOf(manager, Current); - if (h == HIGH(manager)) { - fprintf(outputfile, "TRUE\t0\t"); - } else if (h == LOW(manager)) { - fprintf(outputfile, "FALSE\t0\t"); - } else { - if (GetNode(Nodes, varmap.varstart, h) == NULL) AddNode(Nodes, varmap.varstart, h, 0.0, 0, NULL); - curnode = GetNodeVarNameDisp(manager, varmap, h); - inode = GetNodeIndex(Nodes, varmap.varstart, h); - fprintf(outputfile, "%s\t%i\t", curnode, inode); - } - l = LowNodeOf(manager, Current); - if (l == HIGH(manager)) { - fprintf(outputfile, "TRUE\t0\n"); - } else if (l == LOW(manager)) { - fprintf(outputfile, "FALSE\t0\n"); - } else { - if (GetNode(Nodes, varmap.varstart, l) == NULL) AddNode(Nodes, varmap.varstart, l, 0.0, 0, NULL); - curnode = GetNodeVarNameDisp(manager, varmap, l); - inode = GetNodeIndex(Nodes, varmap.varstart, l); - fprintf(outputfile, "%s\t%i\n", curnode, inode); - } - SaveExpand(manager, varmap, Nodes, l, outputfile); - SaveExpand(manager, varmap, Nodes, h, outputfile); - } - } -} - -DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile) { - hisqueue *Nodes; - nodeline temp; - DdNode *ret; - int i, pos, *perm; - char *varnam; - perm = (int *) malloc(sizeof(int) * varmap.varcnt); - Nodes = InitHistory(varmap.varcnt); - for (i = 0; i < varmap.varcnt; i++) { - varnam = freadstr(inputfile, "\t"); - pos = atoi(freadstr(inputfile, "\n")); - AddNamedVarAt(varmap, varnam, pos); - perm[pos] = pos; - } - temp.varname = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.nodenum); - temp.truevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.truenode); - temp.falsevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\n", &temp.falsenode); - ret = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); - free(temp.varname); - free(temp.truevar); - free(temp.falsevar); - fclose(inputfile); - ReInitHistory(Nodes, varmap.varcnt); - free(Nodes); - Cudd_Ref(ret); - Cudd_ShuffleHeap(manager, perm); - for (i = 0; i < varmap.varcnt; i++) varmap.ivalue[i] = 0; - return ret; -} - -DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current) { - nodeline temp; - DdNode *newnode, *truenode, *falsenode; - int index; - newnode = GetIfExists(manager, varmap, Nodes, current.varname, current.nodenum); - if (newnode != NULL) return newnode; - falsenode = GetIfExists(manager, varmap, Nodes, current.falsevar, current.falsenode); - if (falsenode == NULL) { - temp.varname = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.nodenum); - temp.truevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.truenode); - temp.falsevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\n", &temp.falsenode); - falsenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); - free(temp.varname); - free(temp.truevar); - free(temp.falsevar); - } - truenode = GetIfExists(manager, varmap, Nodes, current.truevar, current.truenode); - if (truenode == NULL) { - temp.varname = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.nodenum); - temp.truevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\t", &temp.truenode); - temp.falsevar = freadstr(inputfile, "\t"); - fscanf(inputfile, "%i\n", &temp.falsenode); - truenode = LoadNodeRec(manager, varmap, Nodes, inputfile, temp); - free(temp.varname); - free(temp.truevar); - free(temp.falsevar); - } - index = GetNamedVarIndex(varmap, current.varname); - if (!varmap.ivalue[index]) { - varmap.ivalue[index] = 1; - newnode = GetVar(manager, varmap.varstart + index); - //Cudd_RecursiveDeref(manager, newnode->type.kids.T); - //Cudd_RecursiveDeref(manager, newnode->type.kids.E); - newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); - newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); - Cudd_Ref(newnode->type.kids.T); - Cudd_Ref(newnode->type.kids.E); - Cudd_Ref(newnode); - } else { - if (_RapidLoad == 1) { - newnode = cuddAllocNode(manager); - if (newnode != NULL) { - newnode->index = varmap.varstart + index; - newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); - newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); - Cudd_Ref(newnode->type.kids.T); - Cudd_Ref(newnode->type.kids.E); - Cudd_Ref(newnode); - } - } else { - newnode = cuddUniqueInter(manager, varmap.varstart + index, Cudd_NotCond(truenode, Cudd_IsComplement(truenode)), Cudd_NotCond(falsenode, Cudd_IsComplement(truenode))); - if (newnode != NULL) { - Cudd_Ref(newnode); - } else { - newnode = cuddAllocNode(manager); - if (newnode != NULL) { - newnode->index = varmap.varstart + index; - newnode->type.kids.T = Cudd_NotCond(truenode, Cudd_IsComplement(truenode)); - newnode->type.kids.E = Cudd_NotCond(falsenode, Cudd_IsComplement(truenode)); - Cudd_Ref(newnode->type.kids.T); - Cudd_Ref(newnode->type.kids.E); - Cudd_Ref(newnode); - } - } - } - } - if (newnode != NULL) { - Nodes[index].thenode[current.nodenum].key = Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); - return Cudd_NotCond(newnode, Cudd_IsComplement(truenode)); - } - return NULL; -} - -DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum) { - int index; - if (strcmp(varname, "TRUE") == 0) return HIGH(manager); - if (strcmp(varname, "FALSE") == 0) return LOW(manager); - index = GetNamedVarIndex(varmap, varname); - if (index == -1 * varmap.varcnt) { - fprintf(stderr, "Error: more variables requested than initialized.\n"); - exit(-1); - } - if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { - index = AddNamedVar(varmap, varname); - } - ExpandNodes(Nodes, index, nodenum); - if (Nodes[index].thenode[nodenum].key != NULL) return Nodes[index].thenode[nodenum].key; - return NULL; -} - -void ExpandNodes(hisqueue *Nodes, int index, int nodenum) { - int i; - if (Nodes[index].cnt > nodenum) return; - Nodes[index].thenode = (hisnode *) realloc(Nodes[index].thenode, (nodenum + 1) * sizeof(hisnode)); - for (i = Nodes[index].cnt; i < nodenum + 1; i++) { - Nodes[index].thenode[i].key = NULL; - Nodes[index].thenode[i].ivalue = 0; - Nodes[index].thenode[i].dvalue = 0.0; - Nodes[index].thenode[i].dynvalue = NULL; - } - Nodes[index].cnt = nodenum + 1; -}; - -int LoadVariableData(namedvars varmap, char *filename) { - FILE *data; - char *dataread, buf, *varname, *dynvalue; - double dvalue = 0.0; - int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; - dynvalue = NULL; - if ((data = fopen(filename, "r")) == NULL) { - perror("fopen"); - return -1; - } - printf("filename %s\n",filename); - dataread = (char *) malloc(sizeof(char) * maxbufsize); - while(!feof(data)) { - index++; - printf("index %d\n",index); - fscanf(data,"@%s\n",dataread); - - varname = (char *) malloc(sizeof(char) * strlen(dataread)); - strcpy(varname, dataread); - varmap.vars[index]=varname; - fscanf(data, "%di\n", &values); - varmap.mvars[index].nVal=values; - varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); - varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); - varmap.mvars[index].booleanVars=(int *)malloc(sizeof(int)*varmap.mvars[index].nBit); - - free(varname); - } - fclose(data); - free(dataread); - return 0; -} - -int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename) { - FILE *data; - char *dataread, buf, *varname, *dynvalue; - double dvalue = 0.0; - int icur = 0,values, maxbufsize = 10, hasvar = 0, index = -1, idat = 0, ivalue = 0,i; - dynvalue = NULL; - if ((data = fopen(filename, "r")) == NULL) { - perror("fopen"); - return -1; - } - dataread = (char *) malloc(sizeof(char) * maxbufsize); - while(!feof(data)) { - index++; - if(fscanf(data,"@%s\n",dataread)<1) break; - varname = (char *) malloc(sizeof(char) * strlen(dataread)); - strcpy(varname, dataread); - varmap.vars[index]=varname; - //printf("vname %d %s\n",index, varmap.vars[index]); - - fscanf(data, "%d\n", &values); - varmap.loaded[index] = 1; - varmap.mvars[index].init=0; - varmap.mvars[index].nVal=values; - varmap.mvars[index].nBit=(int)ceil(log(values)/log(2)); - varmap.mvars[index].probabilities=(double *)malloc(sizeof(double)*values); - varmap.mvars[index].booleanVars=(DdNode **)malloc(sizeof(DdNode *)*varmap.mvars[index].nBit); - for (i=0;ivars = (char **) realloc(varmap->vars, sizeof(char *) * newvarcnt); - varmap->loaded = (int *) realloc(varmap->loaded, sizeof(int) * newvarcnt); - varmap->dvalue = (double *) realloc(varmap->dvalue, sizeof(double) * newvarcnt); - varmap->ivalue = (int *) realloc(varmap->ivalue, sizeof(int) * newvarcnt); - varmap->dynvalue = (void **) realloc(varmap->dynvalue, sizeof(int) * newvarcnt); - for (i = varmap->varcnt; i < newvarcnt; i++) { - varmap->vars[i] = NULL; - varmap->loaded[i] = 0; - varmap->dvalue[i] = 0.0; - varmap->ivalue[i] = 0; - varmap->dynvalue[i] = NULL; - } - varmap->varcnt = newvarcnt; -} - -int AddNamedVarAt(namedvars varmap, const char *varname, int index) { - if (varmap.varcnt > index) { - varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); - strcpy(varmap.vars[index], varname); - return index; - } - return -1; -} - -int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int *value) { - - int index,i,l,nBit; - int *booleanVars; - char * vname; - l=strlen(varname); - //printf("addnamed %s\n",varname); - i=0; - while (varname[i]!='-') - { - i++; - } - vname=(char *)malloc(sizeof(char)*(l+1)); - strncpy(vname,varname,i); - vname[i]='\0'; - //printf("addnamed vname %s\n",vname); - sscanf(varname+i+1,"%d",value); - index= GetNamedVarIndex(varmap, vname); - //printf("index %d\n",index); - //printf("init %d\n",varmap.mvars[index].init); - if (index == -1 * varmap.varcnt) { - return -1; - } else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { - index *= -1; - varmap.vars[index] = (char *) malloc(sizeof(char) * (strlen(varname) + 1)); - } - if (varmap.mvars[index].init==0){ - nBit=varmap.mvars[index].nBit; - booleanVars= varmap.mvars[index].booleanVars; - //Cudd_MakeTreeNode(mgr,boolVars,nBit,MTR_FIXED); - for (i=0;ivars[varmap->varcnt - 1] == NULL) - varmap->varcnt--; - return varmap->varcnt; -} - -int all_loaded(namedvars varmap, int disp) { - int i, res = 1; - for (i = 0; i < varmap.varcnt; i++) { - if (varmap.loaded[i] == 0) { - res = 0; - if (disp) fprintf(stderr, "The variable: %s was not loaded with values.\n", varmap.vars[i]); else return 0; - } - } - return res; -} - -/* Parser */ - -DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader) { - int icomment, maxlinesize, icur, iline, curinter, iequal ; - DdNode *Line, **inter; - char buf, *inputline, *filename; - bddfileheader interfileheader; - long startAt, endAt; - double secs; - - // Initialization of intermediate steps - inter = (DdNode **) malloc(sizeof(DdNode *) * fileheader.intercnt); - for (icur = 0; icur < fileheader.intercnt; icur++) inter[icur] = NULL; - // Read file data - interfileheader.inputfile = NULL; - filename = NULL; // For nested files - iequal = 0; // Flag for encountered = sign - icur = 0; // Pointer for inputline buffer location - iline = 5; // Current file line (first after header) - icomment = 0; // Flag for comments - maxlinesize = 80; // inputline starting buffer size - inputline = (char *) malloc(sizeof(char) * maxlinesize); - while(!feof(fileheader.inputfile)) { - fread(&buf, 1, 1, fileheader.inputfile); - if (buf == ';' || buf == '%' || buf == '$') icomment = 1; - if (buf == '\n') { - if (icomment) icomment = 0; - /* if (iequal > 1) { - fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } else*/ - iequal = 0; - if (icur > 0) { - inputline[icur] = '\0'; - if (inputline[0] != 'L') { - fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - curinter = getInterBDD(inputline); - if (curinter == -1) { - if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { - curinter = atoi(inputline + 1) - 1; - if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { - if (_debug) fprintf(stderr, "Returned: %s\n", inputline); - fclose(fileheader.inputfile); - Line = inter[curinter]; - free(inter); - free(inputline); - return Line; - } else { - fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - } else { - fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] == NULL) { - if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); - filename = getFileName(inputline); - if (filename == NULL) { - startAt = clock(); - Line = LineParser(manager, varmap, inter, fileheader.intercnt, inputline, iline); - endAt = clock(); - secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC)*1000; - //printf("line %e\n",secs); - } else { - interfileheader = ReadFileHeader(filename); - if (interfileheader.inputfile == NULL) { - //Line = simpleBDDload(manager, &varmap, filename); - Line = NULL; - } else { - Line = FileGenerateBDD(manager, varmap, interfileheader); - } - if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); - free(filename); - filename = NULL; - interfileheader.inputfile = NULL; - } - if (Line == NULL) { - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - inter[curinter] = Line; - icur = 0; - } else if (curinter > -1 && curinter < fileheader.intercnt && inter[curinter] != NULL) { - fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } else { - fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - } - iline++; - } else if (buf != ' ' && buf != '\t' && !icomment) { - if (buf == '=') iequal++; - inputline[icur] = buf; - icur += 1; - if (icur == _maxbufsize) { - fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; - } - while (icur > maxlinesize - 1) { - maxlinesize *= 2; - inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); - } - } - } - fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); - fclose(fileheader.inputfile); - free(inter); - free(inputline); - return NULL; -} - - -int getInterBDD(char *function) { - int i, ret; - char *inter; - for (i = 0; i < strlen(function); i++) { - if (function[i] == '=') { - inter = (char *) malloc(sizeof(char) * i); - strncpy(inter, function + 1, i - 1); - inter[i - 1] = '\0'; - if (IsPosNumber(inter)) { - ret = atoi(inter) - 1; - free(inter); - return ret; - } else { - free(inter); - return -1; - } - } - } - return -1; -} - -char* getFileName(const char *function) { - int i = 0; - char *filename; - while(function[i] != '=' && (i + 1) < strlen(function)) i++; - if ((i + 1) < strlen(function)) { - i++; - if (function[i] == '<' && function[strlen(function) - 1] == '>') { - filename = (char *) malloc(sizeof(char) * strlen(function) - i); - strcpy(filename, function + i + 1); - filename[strlen(function) - i - 2] = '\0'; - return filename; - } - } - return NULL; -} - -DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline) { - int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst,value; - long startAt, endAt; - double secs; - DdNode *bdd; - char *term, curoper; - bdd = HIGH(manager); - Cudd_Ref(bdd); - term = NULL; - ivar = -1; - curoper = '*'; - istart = -1; - iend = strlen(function) - 1; - ilength = -1; - symbol = -1; - inegvar = 0; - inegoper = 0; - iconst = 0; - for (i = strlen(function) - 1; i > -1; i--) { - if (symbol == -1 && isOperator(function[i])) { - symbol = i; - istart = i + 1; - ilength = iend - i; - iend = i - 1; - if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { - term = (char *) malloc(sizeof(char) * (ilength + 1)); - strncpy(term, function + istart, ilength); - term[ilength] = '\0'; - } else { - fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); - free(term); - return NULL; - } - } - if (symbol != -1) { - if (term[0] == '~') inegvar = 1; else inegvar = 0; - if (term[0 + inegvar] != 'L') { - // Term is a variable - if (strcmp(term + inegvar, "TRUE") == 0) { - iconst = 1; - } else if (strcmp(term + inegvar, "FALSE") == 0) { - iconst = 1; - inegvar = 1; - } else { - iconst = 0; - //printf("term %s\n",term + inegvar); - ivar = AddNamedMultiVar(manager,varmap, term + inegvar,&value); - //printf("term %s var %d\n",term + inegvar,ivar); - - if (ivar == -1) { - fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); - free(term); - return NULL; - } - } - if (_debug) fprintf(stderr, "%s\n", term); - if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", - Cudd_CountPathsToNonZero(bdd), - Cudd_CountPath(bdd), - Cudd_DagSize(bdd), - Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap.varstart)), - Cudd_CountPath(GetVar(manager, ivar + varmap.varstart)), - Cudd_DagSize(GetVar(manager, ivar + varmap.varstart)) ); - startAt = clock(); - if (!iconst) { - if (inegvar) bdd = BDD_Operator(manager, NOT(GetMVar(manager, ivar + varmap.varstart,value,varmap)), bdd, curoper, inegoper); - else bdd = BDD_Operator(manager, GetMVar(manager, ivar + varmap.varstart,value,varmap), bdd, curoper, inegoper); - } else { - switch(curoper) { - case '+': - if (inegvar ^ inegoper) ; else { - bdd = HIGH(manager); - Cudd_Ref(bdd); - } - break; - case '*': - if (inegvar ^ inegoper) { - bdd = LOW(manager); - Cudd_Ref(bdd); - } - break; - case '#': - if (inegvar ^ inegoper) ; else bdd = NOT(bdd); - break; - } - } - endAt = clock(); - secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); - //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); - if (bdd == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); - free(term); - return NULL; - } - } else { - // Term is an intermediate result - if (IsPosNumber(term + inegvar + 1)) - { - ivar = atoi(term + inegvar + 1) - 1; - } - else { - fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); - free(term); - return NULL; - } - if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); - free(term); - return NULL; - } - if (_debug) fprintf(stderr, "%s\n", term); - if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", - Cudd_CountPathsToNonZero(bdd), - Cudd_CountPath(bdd), - Cudd_DagSize(bdd), - Cudd_CountPathsToNonZero(inter[ivar]), - Cudd_CountPath(inter[ivar]), - Cudd_DagSize(inter[ivar]) ); - startAt = clock(); - if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); - else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); - endAt = clock(); - secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); - //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); - if (bdd == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); - free(term); - return NULL; - } - } - free(term); - term = NULL; - curoper = function[symbol]; - if (curoper == '=') return bdd; - if (function[symbol - 1] == '~') { - inegoper = 1; - i--; - iend--; - } else { - inegoper = 0; - } - symbol = -1; - } - } - return NULL; -} - -DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper) { - switch (Operator) { - case '+': - if (inegoper) return D_BDDNor(manager, bdd1, bdd2); - else return D_BDDOr(manager, bdd1, bdd2); - break; - case '*': - if (inegoper) return D_BDDNand(manager, bdd1, bdd2); - else return D_BDDAnd(manager, bdd1, bdd2); - break; - case '#': - if (inegoper) return D_BDDXnor(manager, bdd1, bdd2); - else return D_BDDXor(manager, bdd1, bdd2); - break; - default: - return NULL; - break; - } -} - -DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap) { - int icomment, maxlinesize, icur, iline, curinter, iequal, iinters, itmp, i; - DdNode *Line, **inter; - char buf, *inputline, *filename; - bddfileheader interfileheader; - // Initialization of intermediate steps - iinters = 1; - inter = (DdNode **) malloc(sizeof(DdNode *) * iinters); - for (icur = 0; icur < iinters; icur++) inter[icur] = NULL; - // Read file data - interfileheader.inputfile = NULL; - filename = NULL; // For nested files - iequal = 0; // Flag for encountered = sign - icur = 0; // Pointer for inputline buffer location - iline = 1; // Current file line (first after header) - icomment = 0; // Flag for comments - maxlinesize = 80; // inputline starting buffer size - inputline = (char *) malloc(sizeof(char) * maxlinesize); - - do { - buf = fgetc(stdin); - if (buf == ';' || buf == '%' || buf == '$') icomment = 1; - if (buf == '\n') { - if (icomment) icomment = 0; - if (iequal > 1) { - fprintf(stderr, "Error at line: %i. Line contains more than 1 equal(=) signs.\n", iline); - free(inter); - free(inputline); - return NULL; - } else iequal = 0; - if (icur > 0) { - inputline[icur] = '\0'; - if (inputline[0] == '@') { - if (inputline[1] == 'e') { - free(inter); - free(inputline); - exit(0); - } else { - itmp = GetParam(inputline, 1); - if (itmp > varmap->varcnt) - EnlargeNamedVars(varmap, itmp); - itmp = GetParam(inputline, 2); - if (itmp > iinters) { - inter = (DdNode **) realloc(inter, sizeof(DdNode *) * itmp); - for (i = iinters; i < itmp; i++) inter[i] = NULL; - iinters = itmp; - } - } - icur = 0; - } else { - if (inputline[0] != 'L') { - fprintf(stderr, "Error at line: %i. Intermediate results should start with L.\n", iline); - free(inter); - free(inputline); - return NULL; - } - curinter = getInterBDD(inputline); - if (curinter == -1) { - if (inputline[0] == 'L' && IsPosNumber(inputline + 1)) { - curinter = atoi(inputline + 1) - 1; - if (curinter > -1 && curinter < iinters && inter[curinter] != NULL) { - if (_debug) fprintf(stderr, "Returned: %s\n", inputline); - Line = inter[curinter]; - free(inter); - free(inputline); - return Line; - } else { - fprintf(stderr, "Error at line: %i. Return result asked doesn't exist.\n", iline); - free(inter); - free(inputline); - return NULL; - } - } else { - fprintf(stderr, "Error at line: %i. Invalid intermediate result format.\n", iline); - free(inter); - free(inputline); - return NULL; - } - } else if (curinter > -1) { - if (curinter >= iinters) { - inter = (DdNode **) realloc(inter, sizeof(DdNode *) * (curinter + 1)); - for (i = iinters; i < curinter + 1; i++) inter[i] = NULL; - iinters = curinter + 1; - } - if (inter[curinter] == NULL) { - if (_debug) fprintf(stderr, "%i %s\n", curinter, inputline); - filename = getFileName(inputline); - if (filename == NULL) { - Line = OnlineLineParser(manager, varmap, inter, iinters, inputline, iline); - } else { - interfileheader = ReadFileHeader(filename); - if (interfileheader.inputfile == NULL) { - //Line = simpleBDDload(manager, varmap, filename); - Line = NULL; - } else { - Line = FileGenerateBDD(manager, *varmap, interfileheader); - } - if (Line == NULL) fprintf(stderr, "Error at line: %i. Error in nested BDD file: %s.\n", iline, filename); - free(filename); - filename = NULL; - interfileheader.inputfile = NULL; - } - if (Line == NULL) { - free(inter); - free(inputline); - return NULL; - } - inter[curinter] = Line; - icur = 0; - } else if (inter[curinter] != NULL) { - fprintf(stderr, "Error at line: %i. Intermediate results can't be overwritten.\n", iline); - free(inter); - free(inputline); - return NULL; - } - } else { - fprintf(stderr, "Error at line: %i. Intermediate result asked doesn't exist.\n", iline); - free(inter); - free(inputline); - return NULL; - } - } - } - iline++; - } else if (buf != ' ' && buf != '\t' && !icomment) { - if (buf == '=') iequal++; - inputline[icur] = buf; - icur += 1; - if (icur == _maxbufsize) { - fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); - free(inter); - free(inputline); - return NULL; - } - while (icur > maxlinesize - 1) { - maxlinesize *= 2; - inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); - } - } - } while(1); - fprintf(stderr, "Error, file either doesn't end with a blank line or no return result was asked.\n"); - free(inter); - free(inputline); - return NULL; -} - -DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline) { - int istart, iend, ilength, i, symbol, ivar, inegvar, inegoper, iconst; - long startAt, endAt; - double secs; - DdNode *bdd; - char *term, curoper; - bdd = HIGH(manager); - Cudd_Ref(bdd); - term = NULL; - ivar = -1; - curoper = '*'; - istart = -1; - iend = strlen(function) - 1; - ilength = -1; - symbol = -1; - inegvar = 0; - inegoper = 0; - iconst = 0; - for (i = strlen(function) - 1; i > -1; i--) { - if (symbol == -1 && isOperator(function[i])) { - symbol = i; - istart = i + 1; - ilength = iend - i; - iend = i - 1; - if (ilength > 0 && !(ilength == 1 && function[istart] == '~')) { - term = (char *) malloc(sizeof(char) * (ilength + 1)); - strncpy(term, function + istart, ilength); - term[ilength] = '\0'; - } else { - fprintf(stderr, "Line Parser Error at line: %i. An operator was encounter with no term at its right side.\n", iline); - free(term); - return NULL; - } - } - if (symbol != -1) { - if (term[0] == '~') inegvar = 1; else inegvar = 0; - if (term[0 + inegvar] != 'L') { - // Term is a variable - if (strcmp(term , "TRUE") == 0) { - iconst = 1; - } else if (strcmp(term , "FALSE") == 0) { - iconst = 1; - inegvar = 1; - } else { - iconst = 0; - ivar = AddNamedVar(*varmap, term + inegvar); - if (ivar == -1) { - EnlargeNamedVars(varmap, varmap->varcnt + 1); - ivar = AddNamedVar(*varmap, term + inegvar); - } - if (ivar == -1) { - fprintf(stderr, "Line Parser Error at line: %i. More BDD variables than the reserved term: %s.\n", iline, term); - free(term); - return NULL; - } - } - if (_debug) fprintf(stderr, "%s\n", term); - if (_debug && !iconst) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", - Cudd_CountPathsToNonZero(bdd), - Cudd_CountPath(bdd), - Cudd_DagSize(bdd), - Cudd_CountPathsToNonZero(GetVar(manager, ivar + varmap->varstart)), - Cudd_CountPath(GetVar(manager, ivar + varmap->varstart)), - Cudd_DagSize(GetVar(manager, ivar + varmap->varstart)) ); - startAt = clock(); - if (!iconst) { - if (inegvar) bdd = BDD_Operator(manager, NOT(GetVar(manager, ivar + varmap->varstart)), bdd, curoper, inegoper); - else bdd = BDD_Operator(manager, GetVar(manager, ivar + varmap->varstart), bdd, curoper, inegoper); - } else { - switch(curoper) { - case '+': - if (inegvar ^ inegoper) ; else { - bdd = HIGH(manager); - Cudd_Ref(bdd); - } - break; - case '*': - if (inegvar ^ inegoper) { - bdd = LOW(manager); - Cudd_Ref(bdd); - } - break; - case '#': - if (inegvar ^ inegoper) ; else bdd = NOT(bdd); - break; - } - } - endAt = clock(); - secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); - //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); - if (bdd == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); - free(term); - return NULL; - } - } else { - // Term is an intermediate result - if (IsPosNumber(term + inegvar + 1)) ivar = atoi(term + inegvar + 1) - 1; else { - fprintf(stderr, "Line Parser Error at line: %i. Invalid intermediate result format term: %s.\n", iline, term); - free(term); - return NULL; - } - if (ivar < 0 || ivar > maxinter || inter[ivar] == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Usage of undeclared intermediate result term: %s.\n", iline, term); - free(term); - return NULL; - } - if (_debug) fprintf(stderr, "%s\n", term); - if (_debug) fprintf(stderr, "PNZ1:%.0f P1:%.0f S1:%i PNZ2:%.0f P2:%.0f S2:%i\n", - Cudd_CountPathsToNonZero(bdd), - Cudd_CountPath(bdd), - Cudd_DagSize(bdd), - Cudd_CountPathsToNonZero(inter[ivar]), - Cudd_CountPath(inter[ivar]), - Cudd_DagSize(inter[ivar]) ); - startAt = clock(); - if (inegvar) bdd = BDD_Operator(manager, NOT(inter[ivar]), bdd, curoper, inegoper); - else bdd = BDD_Operator(manager, inter[ivar], bdd, curoper, inegoper); - endAt = clock(); - secs = ((double) (endAt - startAt)) / ((double) CLOCKS_PER_SEC); - if (_debug) fprintf(stderr, "term: %s of line: %i took: %i\n", term, iline, endAt - startAt); - //if ((endAt - startAt) > 10000000) Cudd_AutodynDisable(manager); - if (bdd == NULL) { - fprintf(stderr, "Line Parser Error at line: %i. Error using operator %c on term: %s.\n", iline, curoper, term); - free(term); - return NULL; - } - } - free(term); - term = NULL; - curoper = function[symbol]; - if (curoper == '=') return bdd; - if (function[symbol - 1] == '~') { - inegoper = 1; - i--; - iend--; - } else { - inegoper = 0; - } - symbol = -1; - } - } - return NULL; -} - -int GetParam(char *inputline, int iParam) { - int icoma, istart, iend, ret; - char *numb; - istart = 1; - icoma = istart; - iend = strlen(inputline); - while((inputline[icoma] != ',') && (icoma < iend)) - icoma++; - if (iParam == 1) { - numb = (char *) malloc(sizeof(char) * icoma); - strncpy(numb, inputline + 1, icoma - 1); - numb[icoma - 1] = '\0'; - if (IsPosNumber(numb)) { - ret = atoi(numb); - free(numb); - return ret; - } - } else if(iParam == 2) { - numb = (char *) malloc(sizeof(char) * (iend - icoma + 1)); - strncpy(numb, inputline + icoma + 1, iend - icoma); - numb[iend - icoma] = '\0'; - if (IsPosNumber(numb)) { - ret = atoi(numb); - free(numb); - return ret; - } - } - return 0; -} - -void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd) { - char buf, *inputline; - int icur, maxlinesize, iline, index, iloop, ivalue, iQsize, i, inQ; - double dvalue; - DdNode **Q, **Q2, *h_node, *l_node, *curnode; - hisqueue *his; - hisnode *hnode; - iloop = 1; - icur = 0; // Pointer for inputline buffer location - iline = 1; // Current file line (first after header) - maxlinesize = 80; // inputline starting buffer size - inputline = (char *) malloc(sizeof(char) * maxlinesize); - curnode = bdd; - iQsize = 0; - Q = (DdNode **) malloc(sizeof(DdNode *) * iQsize); - Q2 = NULL; - his = InitHistory(varmap.varcnt); - do { - buf = fgetc(stdin); - if (buf == '\n') { - inputline[icur] = '\0'; - if ((icur > 0) && (inputline[0] == '@') && (inputline[2] == ',' || inputline[2] == '\0')) { - switch(inputline[1]) { - case 'c': - printf("bdd_temp_value('%s', %i).\n", GetNodeVarNameDisp(manager, varmap, curnode), iQsize); - break; - case 'n': - if (curnode != HIGH(manager) && curnode != LOW(manager) && (hnode = GetNode(his, varmap.varstart, curnode)) == NULL) { - AddNode(his, varmap.varstart, curnode, 0.0, 0, NULL); - l_node = LowNodeOf(manager, curnode); - h_node = HighNodeOf(manager, curnode); - inQ = 0; - for(i = 0; (i < iQsize / 2) && (inQ < 3); i++) - inQ = (Q[i] == l_node) || (Q[iQsize - i] == l_node) + 2 * (Q[i] == h_node) || (Q[iQsize - i] == h_node); - if (inQ & 1 == 0) inQ = inQ + (GetNode(his, varmap.varstart, l_node) != NULL); - if (inQ & 2 == 0) inQ = inQ + 2 * (GetNode(his, varmap.varstart, h_node) != NULL); - if (inQ & 1 == 1) inQ = inQ - (l_node == HIGH(manager) || l_node == LOW(manager)); - if (inQ & 2 == 2) inQ = inQ - 2 * (h_node == HIGH(manager) || h_node == LOW(manager)); - switch(inQ) { - case 0: - iQsize += 2; - Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); - Q[iQsize - 2] = l_node; - Q[iQsize - 1] = h_node; - break; - case 1: - iQsize++; - Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); - Q[iQsize - 1] = h_node; - break; - case 2: - iQsize++; - Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); - Q[iQsize - 1] = l_node; - break; - case 3: - break; - default: - break; - } - } - if (inputline[2] == '\0' || strcmp(inputline + 3, "DFS") == 0) { - if (iQsize > 0) { - iQsize--; - curnode = Q[iQsize]; - Q = (DdNode **) realloc(Q, sizeof(DdNode *) * iQsize); - } - } else if (strcmp(inputline + 3, "BFS") == 0) { - if (iQsize > 0) { - iQsize--; - curnode = Q[0]; - Q2 = (DdNode **) malloc(sizeof(DdNode *) * iQsize); - for(i = 0; i < iQsize; i++) - Q2[i] = Q[i + 1]; - free(Q); - Q = Q2; - } - } else { - fprintf(stderr, "Error: Could not find method: %s, Correct syntax @n,[DFS, BFS].\n", inputline + 3); - free(Q); - free(inputline); - exit(-1); - } - break; - case 'h': - printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, HighNodeOf(manager, curnode))); - break; - case 'l': - printf("bdd_temp_value('%s').\n", GetNodeVarNameDisp(manager, varmap, LowNodeOf(manager, curnode))); - break; - case 'v': - index = GetNamedVarIndex(varmap, inputline + 3); - if (index >= 0) { - fprintf(stdout, "bdd_temp_value([%f,%i,%s]).\n", varmap.dvalue[index], varmap.ivalue[index], (char *) varmap.dynvalue[index]); - } else { - fprintf(stderr, "Error: Could not find variable: %s, Correct syntax @v,[variable name].\n", inputline + 3); - free(Q); - free(inputline); - exit(-1); - } - break; - case 'e': - iloop = 0; - break; - default: - fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); - free(Q); - free(inputline); - exit(-1); - break; - } - icur = 0; - } else { - fprintf(stderr, "Error: Not recognizable instruction: %s.\n", inputline); - free(Q); - free(inputline); - exit(-1); - } - iline++; - } else if (buf != ' ' && buf != '\t') { - inputline[icur] = buf; - icur += 1; - if (icur == _maxbufsize) { - fprintf(stderr, "Error: Maximum buffer size(%i) exceeded.\n", _maxbufsize); - free(Q); - free(inputline); - exit(-1); - } - while (icur > maxlinesize - 1) { - maxlinesize *= 2; - inputline = (char *) realloc(inputline, sizeof(char) * maxlinesize); - } - } - } while(iloop); - free(Q); - free(inputline); -} - -DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap) -{ - - int i; - int bit,*booleanVars,booleanVar; - variable v; - DdNode * node, * tmp; - - - v=varmap.mvars[varIndex]; - booleanVars=v.booleanVars; - i=v.nBit-1; - booleanVar=booleanVars[i]; - bit=value & 01; - if (bit) - { - node=Cudd_bddIthVar(mgr, booleanVar); - } - else - { - node=Cudd_Not(Cudd_bddIthVar(mgr, booleanVar)); - } - value=value>>1; - i--; - - while (i>=0) { - booleanVar=booleanVars[i]; - bit=value & 01; - if (bit) - { - tmp=Cudd_bddAnd(mgr,node,Cudd_bddIthVar(mgr, booleanVar)); - Cudd_Ref(tmp); - } - else - { - tmp=Cudd_bddAnd(mgr,node,Cudd_Not(Cudd_bddIthVar(mgr, booleanVar))); - Cudd_Ref(tmp); - } - value=value>>1; - i--; - Cudd_RecursiveDeref(mgr,node); - node=tmp; - } -return node; -} - - - diff --git a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base b/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base deleted file mode 100644 index 998ad182b..000000000 --- a/packages/cplint/approx/simplecuddLPADs/.svn/text-base/simplecudd.h.svn-base +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis * -* File: simplecudd.h * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include -#include -#include -#include -#include -#include "util.h" -#include "cudd.h" -#include "cuddInt.h" -#include "general.h" - -#define IsHigh(manager, node) HIGH(manager) == node -#define IsLow(manager, node) LOW(manager) == node -#define HIGH(manager) Cudd_ReadOne(manager) -#define LOW(manager) Cudd_Not(Cudd_ReadOne(manager)) -#define NOT(node) Cudd_Not(node) -#define GetIndex(node) Cudd_NodeReadIndex(node) -#define GetMVar(manager, index, value, varmap) equality(manager,index,value,varmap)//Cudd_bddIthVar(manager, index) -#define GetVar(manager, index) Cudd_bddIthVar(manager, index) -#define NewVar(manager) Cudd_bddNewVar(manager) -#define KillBDD(manager) Cudd_Quit(manager) -#define GetVarCount(manager) Cudd_ReadSize(manager) -#define DEBUGON _debug = 1 -#define DEBUGOFF _debug = 0 -#define RAPIDLOADON _RapidLoad = 1 -#define RAPIDLOADOFF _RapidLoad = 0 -#define SETMAXBUFSIZE(size) _maxbufsize = size -#define BDDFILE_ERROR -1 -#define BDDFILE_OTHER 0 -#define BDDFILE_SCRIPT 1 -#define BDDFILE_NODEDUMP 2 - -extern int _RapidLoad; -extern int _debug; -extern int _maxbufsize; - -typedef struct _bddfileheader { - FILE *inputfile; - int version; - int varcnt; - int bvarcnt; - int varstart; - int intercnt; - int filetype; -} bddfileheader; - -typedef struct - { -int nVal,nBit,init; -double * probabilities; -int * booleanVars; -} variable; - -typedef struct _namedvars { - int varcnt; - int varstart; - char **vars; - int *loaded; - double *dvalue; - int *ivalue; - void **dynvalue; - variable * mvars; - int * bVar2mVar; -} namedvars; - - -typedef struct _hisnode { - DdNode *key; - double dvalue; - int ivalue; - void *dynvalue; -} hisnode; - -typedef struct _hisqueue { - int cnt; - hisnode *thenode; -} hisqueue; - -typedef struct _nodeline { - char *varname; - char *truevar; - char *falsevar; - int nodenum; - int truenode; - int falsenode; -} nodeline; - -/* Initialization */ - -DdManager* simpleBDDinit(int varcnt); - -/* BDD Generation */ - -DdNode* D_BDDAnd(DdManager *manager, DdNode *bdd1, DdNode *bdd2); -DdNode* D_BDDNand(DdManager *manager, DdNode *bdd1, DdNode *bdd2); -DdNode* D_BDDOr(DdManager *manager, DdNode *bdd1, DdNode *bdd2); -DdNode* D_BDDNor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); -DdNode* D_BDDXor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); -DdNode* D_BDDXnor(DdManager *manager, DdNode *bdd1, DdNode *bdd2); - -DdNode* FileGenerateBDD(DdManager *manager, namedvars varmap, bddfileheader fileheader); -DdNode* OnlineGenerateBDD(DdManager *manager, namedvars *varmap); -DdNode* LineParser(DdManager *manager, namedvars varmap, DdNode **inter, int maxinter, char *function, int iline); -DdNode* OnlineLineParser(DdManager *manager, namedvars *varmap, DdNode **inter, int maxinter, char *function, int iline); -DdNode* BDD_Operator(DdManager *manager, DdNode *bdd1, DdNode *bdd2, char Operator, int inegoper); -int getInterBDD(char *function); -char* getFileName(const char *function); -int GetParam(char *inputline, int iParam); -int LoadVariableData(namedvars varmap, char *filename); -int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename); - -/* Named variables */ - -namedvars InitNamedVars(int varcnt, int varstart); -namedvars InitNamedMultiVars(int varcnt, int varstart, int bvarcnt); -void EnlargeNamedVars(namedvars *varmap, int newvarcnt); -int AddNamedVarAt(namedvars varmap, const char *varname, int index); -int AddNamedVar(namedvars varmap, const char *varname); -int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varnamei, int *value); -void SetNamedVarValuesAt(namedvars varmap, int index, double dvalue, int ivalue, void *dynvalue); -int SetNamedVarValues(namedvars varmap, const char *varname, double dvalue, int ivalue, void *dynvalue); -int GetNamedVarIndex(const namedvars varmap, const char *varname); -int RepairVarcnt(namedvars *varmap); -char* GetNodeVarName(DdManager *manager, namedvars varmap, DdNode *node); -char* GetNodeVarNameDisp(DdManager *manager, namedvars varmap, DdNode *node); -int all_loaded(namedvars varmap, int disp); - -/* Traversal */ - -DdNode* HighNodeOf(DdManager *manager, DdNode *node); -DdNode* LowNodeOf(DdManager *manager, DdNode *node); - -/* Traversal - History */ - -hisqueue* InitHistory(int varcnt); -void ReInitHistory(hisqueue *HisQueue, int varcnt); -void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); -hisnode* GetNode(hisqueue *HisQueue, int varstart, DdNode *node); -int GetNodeIndex(hisqueue *HisQueue, int varstart, DdNode *node); -void onlinetraverse(DdManager *manager, namedvars varmap, hisqueue *HisQueue, DdNode *bdd); - -/* Save-load */ - -bddfileheader ReadFileHeader(char *filename); -int CheckFileVersion(const char *version); - -DdNode * LoadNodeDump(DdManager *manager, namedvars varmap, FILE *inputfile); -DdNode * LoadNodeRec(DdManager *manager, namedvars varmap, hisqueue *Nodes, FILE *inputfile, nodeline current); -DdNode * GetIfExists(DdManager *manager, namedvars varmap, hisqueue *Nodes, char *varname, int nodenum); - -int SaveNodeDump(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); -void SaveExpand(DdManager *manager, namedvars varmap, hisqueue *Nodes, DdNode *Current, FILE *outputfile); -void ExpandNodes(hisqueue *Nodes, int index, int nodenum); - -/* Export */ - -int simpleBDDtoDot(DdManager *manager, DdNode *bdd, char *filename); -int simpleNamedBDDtoDot(DdManager *manager, namedvars varmap, DdNode *bdd, char *filename); - -DdNode * equality(DdManager *mgr,int varIndex,int value,namedvars varmap); -hisnode* GetNodei1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); -void AddNode1(int *bVar2mVar, hisqueue *HisQueue, int varstart, DdNode *node, double dvalue, int ivalue, void *dynvalue); -hisnode* GetNode1(int *bVar2mVar,hisqueue *HisQueue, int varstart, DdNode *node); From 287317721eee3cc7d89ab64a7da645367288fa07 Mon Sep 17 00:00:00 2001 From: RIGUZZI FABRIZIO - Dipartimento di Ingegneria Date: Sat, 20 Mar 2010 01:08:30 +0100 Subject: [PATCH 4/6] added comments to simplecuddLPADs files stating they were modified from Problog --- .../approx/simplecuddLPADs/ProblogBDDclus.c | 895 ------------------ 1 file changed, 895 deletions(-) delete mode 100644 packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c diff --git a/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c b/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c deleted file mode 100644 index a799895bc..000000000 --- a/packages/cplint/approx/simplecuddLPADs/ProblogBDDclus.c +++ /dev/null @@ -1,895 +0,0 @@ -/******************************************************************************\ -* * -* SimpleCUDD library (www.cs.kuleuven.be/~theo/tools/simplecudd.html) * -* SimpleCUDD was developed at Katholieke Universiteit Leuven(www.kuleuven.be) * -* * -* Copyright T. Mantadelis, A. Kimmig, B. Gutmann * -* and Katholieke Universiteit Leuven 2008 * -* * -* Author: Theofrastos Mantadelis, Angelika Kimmig, Bernd Gutmann * -* File: ProblogBDD.c * -* * -******************************************************************************** -* * -* The "Artistic License" * -* * -* Preamble * -* * -* The intent of this document is to state the conditions under which a * -* Package may be copied, such that the Copyright Holder maintains some * -* semblance of artistic control over the development of the package, * -* while giving the users of the package the right to use and distribute * -* the Package in a more-or-less customary fashion, plus the right to make * -* reasonable modifications. * -* * -* Definitions: * -* * -* "Package" refers to the collection of files distributed by the * -* Copyright Holder, and derivatives of that collection of files * -* created through textual modification. * -* * -* "Standard Version" refers to such a Package if it has not been * -* modified, or has been modified in accordance with the wishes * -* of the Copyright Holder as specified below. * -* * -* "Copyright Holder" is whoever is named in the copyright or * -* copyrights for the package. * -* * -* "You" is you, if you're thinking about copying or distributing * -* this Package. * -* * -* "Reasonable copying fee" is whatever you can justify on the * -* basis of media cost, duplication charges, time of people involved, * -* and so on. (You will not be required to justify it to the * -* Copyright Holder, but only to the computing community at large * -* as a market that must bear the fee.) * -* * -* "Freely Available" means that no fee is charged for the item * -* itself, though there may be fees involved in handling the item. * -* It also means that recipients of the item may redistribute it * -* under the same conditions they received it. * -* * -* 1. You may make and give away verbatim copies of the source form of the * -* Standard Version of this Package without restriction, provided that you * -* duplicate all of the original copyright notices and associated disclaimers. * -* * -* 2. You may apply bug fixes, portability fixes and other modifications * -* derived from the Public Domain or from the Copyright Holder. A Package * -* modified in such a way shall still be considered the Standard Version. * -* * -* 3. You may otherwise modify your copy of this Package in any way, provided * -* that you insert a prominent notice in each changed file stating how and * -* when you changed that file, and provided that you do at least ONE of the * -* following: * -* * -* a) place your modifications in the Public Domain or otherwise make them * -* Freely Available, such as by posting said modifications to Usenet or * -* an equivalent medium, or placing the modifications on a major archive * -* site such as uunet.uu.net, or by allowing the Copyright Holder to include * -* your modifications in the Standard Version of the Package. * -* * -* b) use the modified Package only within your corporation or organization. * -* * -* c) rename any non-standard executables so the names do not conflict * -* with standard executables, which must also be provided, and provide * -* a separate manual page for each non-standard executable that clearly * -* documents how it differs from the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 4. You may distribute the programs of this Package in object code or * -* executable form, provided that you do at least ONE of the following: * -* * -* a) distribute a Standard Version of the executables and library files, * -* together with instructions (in the manual page or equivalent) on where * -* to get the Standard Version. * -* * -* b) accompany the distribution with the machine-readable source of * -* the Package with your modifications. * -* * -* c) give non-standard executables non-standard names, and clearly * -* document the differences in manual pages (or equivalent), together * -* with instructions on where to get the Standard Version. * -* * -* d) make other distribution arrangements with the Copyright Holder. * -* * -* 5. You may charge a reasonable copying fee for any distribution of this * -* Package. You may charge any fee you choose for support of this * -* Package. You may not charge a fee for this Package itself. However, * -* you may distribute this Package in aggregate with other (possibly * -* commercial) programs as part of a larger (possibly commercial) software * -* distribution provided that you do not advertise this Package as a * -* product of your own. You may embed this Package's interpreter within * -* an executable of yours (by linking); this shall be construed as a mere * -* form of aggregation, provided that the complete Standard Version of the * -* interpreter is so embedded. * -* * -* 6. The scripts and library files supplied as input to or produced as * -* output from the programs of this Package do not automatically fall * -* under the copyright of this Package, but belong to whoever generated * -* them, and may be sold commercially, and may be aggregated with this * -* Package. If such scripts or library files are aggregated with this * -* Package via the so-called "undump" or "unexec" methods of producing a * -* binary executable image, then distribution of such an image shall * -* neither be construed as a distribution of this Package nor shall it * -* fall under the restrictions of Paragraphs 3 and 4, provided that you do * -* not represent such an executable image as a Standard Version of this * -* Package. * -* * -* 7. C subroutines (or comparably compiled subroutines in other * -* languages) supplied by you and linked into this Package in order to * -* emulate subroutines and variables of the language defined by this * -* Package shall not be considered part of this Package, but are the * -* equivalent of input as in Paragraph 6, provided these subroutines do * -* not change the language in any way that would cause it to fail the * -* regression tests for the language. * -* * -* 8. Aggregation of this Package with a commercial distribution is always * -* permitted provided that the use of this Package is embedded; that is, * -* when no overt attempt is made to make this Package's interfaces visible * -* to the end user of the commercial distribution. Such use shall not be * -* construed as a distribution of this Package. * -* * -* 9. The name of the Copyright Holder may not be used to endorse or promote * -* products derived from this software without specific prior written * -* permission. * -* * -* 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * -* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * -* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * -* * -* The End * -* * -\******************************************************************************/ - - -#include "simplecudd.h" -#include - -typedef struct _parameters { - int loadfile; - int savedfile; - int exportfile; - int inputfile; - int debug; - int errorcnt; - int *error; - int method; - int queryid; - int timeout; - double sigmoid_slope; - int online; - int maxbufsize; - char *ppid; -} parameters; - -typedef struct _gradientpair { - double probability; - double gradient; -} gradientpair; - -typedef struct _extmanager { - DdManager *manager; - DdNode *t, *f; - hisqueue *his; - namedvars varmap; -} extmanager; - -GHashTable * nodes; /* hash table that associates nodes with their probability if already - computed, it is defined in glib */ -unsigned long dividend; - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp); -double Prob(extmanager MyManager, DdNode *node, int comp); -int correctPosition(int index,variable v, DdNode * node,int posBVar); -gint my_equal(gconstpointer v,gconstpointer v2); -guint my_hash(gconstpointer key); -void dealloc(gpointer key,gpointer value,gpointer user_data); -double ret_prob(extmanager MyManager, DdNode * bdd); - - - -int argtype(const char *arg); -void printhelp(int argc, char **arg); -parameters loadparam(int argc, char **arg); -parameters params; - -void handler(int num); -void pidhandler(int num); -void termhandler(int num); - -double sigmoid(double x, double slope); -void myexpand(extmanager MyManager, DdNode *Current); -double CalcProbability(extmanager MyManager, DdNode *Current); -double CalcProbabilitySigmoid(extmanager MyManager, DdNode *Current); -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern); -int patterncalculated(char *pattern, extmanager MyManager, int loc); -char * extractpattern(char *thestr); - -int main(int argc, char **arg) { - extmanager MyManager; - DdNode *bdd; - bddfileheader fileheader; - int i, ivarcnt, code; - gradientpair tvalue; - double probability = -1.0; - char *varpattern; - varpattern = NULL; - code = -1; - params = loadparam(argc, arg); - if (params.errorcnt > 0) { - printhelp(argc, arg); - for (i = 0; i < params.errorcnt; i++) { - fprintf(stderr, "Error: not known or error at parameter %s.\n", arg[params.error[i]]); - } - return -1; - } - - if (params.online == 0 && params.loadfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: you must specify a loading file.\n"); - return -1; - } - - if (params.method != 0 && arg[params.method][0] != 'g' && arg[params.method][0] != 'p' && arg[params.method][0] != 'o' && arg[params.method][0] != 'l') { - printhelp(argc, arg); - fprintf(stderr, "Error: you must choose a calculation method beetween [p]robability, [g]radient, [l]ine search, [o]nline.\n"); - return -1; - } - - if (params.debug) DEBUGON; - RAPIDLOADON; - SETMAXBUFSIZE(params.maxbufsize); - - signal(SIGINT, termhandler); - if (params.ppid != NULL) { - signal(SIGALRM, pidhandler); - alarm(5); - } else { - signal(SIGALRM, handler); - alarm(params.timeout); - } - if (params.online) { - MyManager.manager = simpleBDDinit(0); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(1, 0); - bdd = OnlineGenerateBDD(MyManager.manager, &MyManager.varmap); - ivarcnt = GetVarCount(MyManager.manager); - } else { - fileheader = ReadFileHeader(arg[params.loadfile]); - switch(fileheader.filetype) { - case BDDFILE_SCRIPT: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedMultiVars(fileheader.varcnt, fileheader.varstart,fileheader.bvarcnt); - if (LoadMultiVariableData(MyManager.manager,MyManager.varmap, arg[params.inputfile]) == -1) return -1; - bdd = FileGenerateBDD(MyManager.manager, MyManager.varmap, fileheader); - ivarcnt = fileheader.varcnt; - break; - case BDDFILE_NODEDUMP: - if (params.inputfile == -1) { - printhelp(argc, arg); - fprintf(stderr, "Error: an input file is necessary for this type of loading file.\n"); - return -1; - } - MyManager.manager = simpleBDDinit(fileheader.varcnt); - MyManager.t = HIGH(MyManager.manager); - MyManager.f = LOW(MyManager.manager); - MyManager.varmap = InitNamedVars(fileheader.varcnt, fileheader.varstart); - bdd = LoadNodeDump(MyManager.manager, MyManager.varmap, fileheader.inputfile); - ivarcnt = fileheader.varcnt; - break; - default: - fprintf(stderr, "Error: not a valid file format to load.\n"); - return -1; - break; - } - } - alarm(0); - - // problem specifics - - if (bdd != NULL) { - ivarcnt = RepairVarcnt(&MyManager.varmap); - code = 0; - /* - if (params.inputfile != -1) { - if (LoadVariableData(MyManager.varmap, arg[params.inputfile]) == -1) return -1; - if (!all_loaded(MyManager.varmap, 1)) return -1; - }*/ - MyManager.his = InitHistory(ivarcnt); - if (params.method != 0) { - switch(arg[params.method][0]) { - case 'g': - for (i = 0; i < MyManager.varmap.varcnt; i++) { - if (MyManager.varmap.vars[i] != NULL) { - varpattern = extractpattern(MyManager.varmap.vars[i]); - if ((varpattern == NULL) || (!patterncalculated(varpattern, MyManager, i))) { - tvalue = CalcGradient(MyManager, bdd, i + MyManager.varmap.varstart, varpattern); - probability = tvalue.probability; - double factor = sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope) * (1 - sigmoid(MyManager.varmap.dvalue[i], params.sigmoid_slope)) * params.sigmoid_slope; - if (varpattern == NULL) { - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], MyManager.varmap.vars[i], tvalue.gradient * factor); - } else { - varpattern[strlen(varpattern) - 2] = '\0'; - printf("query_gradient(%s,%s,%1.12f).\n", arg[params.queryid], varpattern, tvalue.gradient * factor); - } - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - } - if (varpattern != NULL) free(varpattern); - } else { - fprintf(stderr, "Error: no variable name given for parameter.\n"); - } - } - if (probability < 0.0) { - // no nodes, so we have to calculate probability ourself - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - } - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'l': - tvalue = CalcGradient(MyManager, bdd, 0 + MyManager.varmap.varstart, NULL); - probability = tvalue.probability; - printf("query_probability(%s,%1.12f).\n", arg[params.queryid], probability); - break; - case 'p': - printf("probability(%1.12f).\n", CalcProbability(MyManager, bdd)); - break; - case 'o': - onlinetraverse(MyManager.manager, MyManager.varmap, MyManager.his, bdd); - break; - default: - myexpand(MyManager, bdd); - break; - } - } else { - //simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, "bdd.dot"); - printf("probability(%1.12f).\n", ret_prob(MyManager, bdd)); -// myexpand(MyManager, bdd); - } - if (params.savedfile > -1) SaveNodeDump(MyManager.manager, MyManager.varmap, bdd, arg[params.savedfile]); - if (params.exportfile > -1) simpleNamedBDDtoDot(MyManager.manager, MyManager.varmap, bdd, arg[params.exportfile]); - ReInitHistory(MyManager.his, MyManager.varmap.varcnt); - free(MyManager.his); - } - if (MyManager.manager != NULL) { - KillBDD(MyManager.manager); - free(MyManager.varmap.dvalue); - free(MyManager.varmap.ivalue); - free(MyManager.varmap.dynvalue); - for (i = 0; i < MyManager.varmap.varcnt; i++) - { - free(MyManager.varmap.vars[i]); - free(MyManager.varmap.mvars[i].probabilities); - free(MyManager.varmap.mvars[i].booleanVars); - } - free(MyManager.varmap.vars); - free(MyManager.varmap.mvars); - free(MyManager.varmap.bVar2mVar); - } - if (params.error != NULL) free(params.error); - - return code; - -} - -/* Shell Parameters handling */ - -int argtype(const char *arg) { - if (strcmp(arg, "-l") == 0 || strcmp(arg, "--load") == 0) return 0; - if (strcmp(arg, "-e") == 0 || strcmp(arg, "--export") == 0) return 2; - if (strcmp(arg, "-m") == 0 || strcmp(arg, "--method") == 0) return 3; - if (strcmp(arg, "-i") == 0 || strcmp(arg, "--input") == 0) return 4; - if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) return 5; - if (strcmp(arg, "-d") == 0 || strcmp(arg, "--debug") == 0) return 6; - if (strcmp(arg, "-id") == 0 || strcmp(arg, "--queryid") == 0) return 7; - if (strcmp(arg, "-t") == 0 || strcmp(arg, "--timeout") == 0) return 8; - if (strcmp(arg, "-sd") == 0 || strcmp(arg, "--savedump") == 0) return 9; - if (strcmp(arg, "-sl") == 0 || strcmp(arg, "--slope") == 0) return 10; - if (strcmp(arg, "-o") == 0 || strcmp(arg, "--online") == 0) return 11; - if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12; - if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13; - return -1; -} - -void printhelp(int argc, char **arg) { - fprintf(stderr, "\nUsage: %s -l [filename] -i [filename] -o (-s(d) [filename] -e [filename] -m [method] -id [queryid] -sl [double]) (-t [seconds] -d -h)\n", arg[0]); - fprintf(stderr, "Generates and traverses a BDD\nMandatory parameters:\n"); - fprintf(stderr, "\t-l [filename]\t->\tfilename to load supports two formats:\n\t\t\t\t\t\t1. script with generation instructions\n\t\t\t\t\t\t2. node dump saved file\n"); - fprintf(stderr, "\t-i [filename]\t->\tfilename to input problem specifics (mandatory with file formats 1, 2)\n"); - fprintf(stderr, "\t-o\t\t->\tgenerates the BDD in online mode instead from a file can be used instead of -l\n"); - fprintf(stderr, "Optional parameters:\n"); - fprintf(stderr, "\t-sd [filename]\t->\tfilename to save generated BDD in node dump format (fast loading, traverse valid only)\n"); - fprintf(stderr, "\t-e [filename]\t->\tfilename to export generated BDD in dot format\n"); - fprintf(stderr, "\t-m [method]\t->\tthe calculation method to be used: none(default), [p]robability, [g]radient, [o]nline\n"); - fprintf(stderr, "\t-id [queryid]\t->\tthe queries identity name (used by gradient) default: %s\n", arg[0]); - fprintf(stderr, "\t-sl [double]\t->\tthe sigmoid slope (used by gradient) default: 1.0\n"); - fprintf(stderr, "Extra parameters:\n"); - fprintf(stderr, "\t-t [seconds]\t->\tthe seconds (int) for BDD generation timeout default 0 = no timeout\n"); - fprintf(stderr, "\t-pid [pid]\t->\ta process id (int) to check for termination default 0 = no process to check works only under POSIX OS\n"); - fprintf(stderr, "\t-bs [bytes]\t->\tthe bytes (int) to use as a maximum buffer size to read files default 0 = no max\n"); - fprintf(stderr, "\t-d\t\t->\tRun in debug mode (gives extra messages in stderr)\n"); - fprintf(stderr, "\t-h\t\t->\tHelp (displays this message)\n\n"); - fprintf(stderr, "Example: %s -l testbdd -i input.txt -m g -id testbdd\n", arg[0]); -} - -parameters loadparam(int argc, char **arg) { - int i; - parameters params; - params.loadfile = -1; - params.savedfile = -1; - params.exportfile = -1; - params.method = 0; - params.inputfile = -1; - params.debug = 0; - params.errorcnt = 0; - params.queryid = 0; - params.timeout = 0; - params.sigmoid_slope = 1.0; - params.online = 0; - params.maxbufsize = 0; - params.ppid = NULL; - params.error = (int *) malloc(argc * sizeof(int)); - for (i = 1; i < argc; i++) { - switch(argtype(arg[i])) { - case 0: - if (argc > i + 1) { - i++; - params.loadfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 2: - if (argc > i + 1) { - i++; - params.exportfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 3: - if (argc > i + 1) { - i++; - params.method = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 4: - if (argc > i + 1) { - i++; - params.inputfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 5: - printhelp(argc, arg); - break; - case 6: - params.debug = 1; - break; - case 7: - if (argc > i + 1) { - i++; - params.queryid = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 8: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.timeout = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 9: - if (argc > i + 1) { - i++; - params.savedfile = i; - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 10: - if ((argc > i + 1) && (IsRealNumber(arg[i + 1]))) { - i++; - params.sigmoid_slope = atof(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 11: - params.online = 1; - break; - case 12: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.maxbufsize = atoi(arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - case 13: - if ((argc > i + 1) && (IsPosNumber(arg[i + 1]))) { - i++; - params.ppid = (char *) malloc(sizeof(char) * (strlen(arg[i]) + 1)); - strcpy(params.ppid, arg[i]); - } else { - params.error[params.errorcnt] = i; - params.errorcnt++; - } - break; - default: - params.error[params.errorcnt] = i; - params.errorcnt++; - break; - } - } - return params; -} - -/* Error Handlers */ - -void handler(int num) { - fprintf(stderr, "Error: Timeout %i exceeded.\n", params.timeout); - exit(-1); -} - -void pidhandler(int num) { - char *s; - if (params.timeout > 0) { - params.timeout -= 5; - if (params.timeout <= 0) { - fprintf(stderr, "Error: Timeout exceeded.\n"); - exit(-1); - } - } - s = (char *) malloc(sizeof(char) * (19 + strlen(params.ppid))); - strcpy(s, "ps "); strcat(s, params.ppid); strcat(s, " >/dev/null"); - if (system(s) != 0) exit(4); - signal(SIGALRM, pidhandler); - alarm(5); - free(s); -} - -void termhandler(int num) { - exit(3); -} - -/* General Functions */ - -double sigmoid(double x, double slope) { - return 1 / (1 + exp(-x * slope)); -} - -/* Debugging traverse function */ - -void myexpand(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - printf("%s\n", curnode); - if ((Current != MyManager.t) && (Current != MyManager.f) && - ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) == NULL)) { - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - printf("l(%s)->", curnode); - myexpand(MyManager, l); - printf("h(%s)->", curnode); - myexpand(MyManager, h); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, 0.0, 0, NULL); - } -} - -/* Angelikas Algorithm */ - -double CalcProbability(extmanager MyManager, DdNode *Current) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - double lvalue, hvalue, tvalue; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) return 1.0; - if (Current == MyManager.f) return 0.0; - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) return Found->dvalue; - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcProbability(MyManager, l); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcProbability(MyManager, h); - tvalue = MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart]; - tvalue = tvalue * hvalue + lvalue * (1.0 - tvalue); - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue, 0, NULL); - return tvalue; -} - -/* Bernds Algorithm */ - -gradientpair CalcGradient(extmanager MyManager, DdNode *Current, int TargetVar, char *TargetPattern) { - DdNode *h, *l; - hisnode *Found; - char *curnode; - gradientpair lvalue, hvalue, tvalue; - double this_probability; - double *gradient; - if (params.debug) { - curnode = GetNodeVarNameDisp(MyManager.manager, MyManager.varmap, Current); - fprintf(stderr, "%s\n", curnode); - } - if (Current == MyManager.t) { - tvalue.probability = 1.0; - tvalue.gradient = 0.0; - return tvalue; - } - if (Current == MyManager.f) { - tvalue.probability = 0.0; - tvalue.gradient = 0.0; - return tvalue; - } - if ((Found = GetNode(MyManager.his, MyManager.varmap.varstart, Current)) != NULL) { - tvalue.probability = Found->dvalue; - tvalue.gradient = *((double *) Found->dynvalue); - return tvalue; - } - l = LowNodeOf(MyManager.manager, Current); - h = HighNodeOf(MyManager.manager, Current); - if (params.debug) fprintf(stderr, "l(%s)->", curnode); - lvalue = CalcGradient(MyManager, l, TargetVar, TargetPattern); - if (params.debug) fprintf(stderr, "h(%s)->", curnode); - hvalue = CalcGradient(MyManager, h, TargetVar, TargetPattern); - this_probability = sigmoid(MyManager.varmap.dvalue[GetIndex(Current) - MyManager.varmap.varstart], params.sigmoid_slope); - tvalue.probability = this_probability * hvalue.probability + (1 - this_probability) * lvalue.probability; - tvalue.gradient = this_probability * hvalue.gradient + (1 - this_probability) * lvalue.gradient; - if ((GetIndex(Current) == TargetVar) || - ((TargetPattern != NULL) && patternmatch(TargetPattern, MyManager.varmap.vars[GetIndex(Current)]))) { - tvalue.gradient += hvalue.probability - lvalue.probability; - } - gradient = (double *) malloc(sizeof(double)); - *gradient = tvalue.gradient; - AddNode(MyManager.his, MyManager.varmap.varstart, Current, tvalue.probability, 0, gradient); - return tvalue; -} - -char * extractpattern(char *thestr) { - char *p; - int i = 0, sl = strlen(thestr); - while((thestr[i] != '_') && (i < sl)) i++; - if (i == sl) return NULL; - i++; - p = (char *) malloc(sizeof(char) * (i + 2)); - strncpy(p, thestr, i); - p[i] = '*'; - p[i + 1] = '\0'; - return p; -} - -int patterncalculated(char *pattern, extmanager MyManager, int loc) { - int i; - if (pattern == NULL) return 0; - for (i = loc - 1; i > -1; i--) - if (patternmatch(pattern, MyManager.varmap.vars[i])) return 1; - return 0; -} - -double Prob(extmanager MyManager, DdNode *node, int comp) -/* compute the probability of the expression rooted at node -nodes is used to store nodes for which the probability has alread been computed -so that it is not recomputed - */ -{ - int index,mVarIndex,nBit; - variable v; - hisnode *Found; - double res; - double value; - - - //index=node->index; - //printf("Prob node %d\n",node); - //index=Cudd_NodeReadIndex(node); - //printf("Prob INdex %d\n",index); - if (Cudd_IsConstant(node)) - { - value=Cudd_V(node);//node->type.value; - //printf("Value %e comp %d\n",value,comp); - if (comp)//Cudd_IsComplement(node)) - //return (1.0-value); - //if (value>0) - { -// printf("return 0"); - return 0.0; - } - else - { -// printf("return 1"); - return 1.0; - } -/*else - if (value>0) - return 1.0; - else - return 0.0; -*/ //return value; - } - else -{ - Found = GetNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node); - - if (Found!=NULL) - { - //printf("value found %e\n",*value_p); - return Found->dvalue; - } - else - { - index=Cudd_NodeReadIndex(node); - //printf("node absent %d comp %d\n",node,comp); - //mVarIndex=array_fetch(int,bVar2mVar,index); - mVarIndex=MyManager.varmap.bVar2mVar[index]; - //v=array_fetch(variable,vars,mVarIndex); - v=MyManager.varmap.mvars[mVarIndex]; - nBit=v.nBit; -// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); - //scanf("%d",&r); - res=ProbBool(MyManager,node,0,nBit,0,v,comp); - //printf("New val %e\n",res); - AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); - return res; - } -} -} - -double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBVar,variable v, int comp) -/* explores a group of binary variables making up the multivalued variable v */ -{ - DdNode *T,*F; - double p,res; - double * probs; - int index; -// printf("ProbBool nBit %d\n",nBit); - //scanf("%d",&r); - probs=v.probabilities; - if (nBit==0) - { - //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); -// printf("bits %d v.nbit %d\n",bits,v.nBit); - if (bits>=v.nVal) - //if (comp) - { - //printf("bits>=v.nbit return 0\n"); - return 0.0; - } - //else - //{printf("return 0\n"); - //return 1.0;}} - else - { - // printf("Val %d\n",bits); - - //p=array_fetch(double,probs,bits); - p=probs[bits]; - //printf("prob %e\n",p); - res=p*Prob(MyManager,node,comp); - //printf("prob %e\n",p); - //printf("bottom %e\n",res); - return res; - } - } - else - { - //if (correctPosition(node->index,v,node,posBVar)) - index=Cudd_NodeReadIndex(node); - //printf("index %d\n",Cudd_NodeReadIndex(node)); - if (correctPosition(index,v,node,posBVar)) - { - //printf("node %d\n",node); - T = Cudd_T(node);//node->type.kids.T; - F = Cudd_E(node);//node->type.kids.E; - bits=bits<<1; - //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); - res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); - //printf("comp %d ",comp); - comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); - //printf("comp %d \n",comp); -res=res+ - ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); - //printf("res 2 %e\n",res); - return res; - } - else - { - //printf("absent var\n"); - bits=bits<<1; - // printf("Var =1\n"); - res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res 1 %e\n",res); -//printf("var =0\n"); - res=res+ - ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); - // printf("res 2 %e\n",res); -return res; - } - } -} - -int correctPosition(int index,variable v, DdNode * node,int posBVar) -/* returns 1 is the boolean variable with index posBVar is in the correct position -currently explored by ProbBool */ -{ - DdNode * bvar; -//printf("posbvar %d\n",posBVar); -//printf("length %d\n",array_n(v.booleanVars)); - //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); - bvar=v.booleanVars[posBVar]; - - // return var->index==index; -return(Cudd_NodeReadIndex(bvar)==index); -} - -gint my_equal(gconstpointer v,gconstpointer v2) -/* function used by GHashTable to compare two keys */ -{ - DdNode *a,*b; - a=*(DdNode **)v; - b=*(DdNode **)v2; - return (a==b); -} -guint my_hash(gconstpointer key) -/* function used by GHashTable to hash a key */ -{ - unsigned int h; - h=(unsigned int)((unsigned long) *((DdNode **)key) % dividend); - return h; -} -void dealloc(gpointer key,gpointer value,gpointer user_data) -{ - free(key); - free(value); -} -double ret_prob(extmanager MyManager, DdNode * bdd) -{ - int intBits,j; - double prob; - nodes=g_hash_table_new(my_hash,my_equal); - intBits=sizeof(unsigned int)*8; - /* dividend is a global variable used by my_hash - it is equal to an unsigned int with binary representation 11..1 */ - dividend=1; - for(j=1;j Date: Sat, 20 Mar 2010 15:26:23 +0100 Subject: [PATCH 5/6] changed the name of the module ptree to ptree_lpad --- packages/cplint/approx/{tptreefile.pl => tptree_lpad.pl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/cplint/approx/{tptreefile.pl => tptree_lpad.pl} (100%) diff --git a/packages/cplint/approx/tptreefile.pl b/packages/cplint/approx/tptree_lpad.pl similarity index 100% rename from packages/cplint/approx/tptreefile.pl rename to packages/cplint/approx/tptree_lpad.pl From b2238c1644707a50e187f2bc15e8b159c11df555 Mon Sep 17 00:00:00 2001 From: RIGUZZI FABRIZIO - Dipartimento di Ingegneria Date: Sun, 21 Mar 2010 11:49:19 +0100 Subject: [PATCH 6/6] removed debug printf, changed module tptree name --- packages/cplint/approx/bestfirst.pl | 2 +- packages/cplint/approx/bestk.pl | 2 +- packages/cplint/approx/deepdyn.pl | 2 +- packages/cplint/approx/deepit.pl | 2 +- packages/cplint/approx/exact.pl | 2 +- .../approx/simplecuddLPADs/ProblogBDD.c | 68 +++---------------- .../cplint/approx/simplecuddLPADs/general.c | 5 ++ .../cplint/approx/simplecuddLPADs/general.h | 5 ++ .../approx/simplecuddLPADs/simplecudd.c | 21 ++---- .../approx/simplecuddLPADs/simplecudd.h | 5 ++ packages/cplint/approx/tptree_lpad.pl | 8 ++- 11 files changed, 44 insertions(+), 78 deletions(-) diff --git a/packages/cplint/approx/bestfirst.pl b/packages/cplint/approx/bestfirst.pl index 8f5cf20ee..f7c162f83 100644 --- a/packages/cplint/approx/bestfirst.pl +++ b/packages/cplint/approx/bestfirst.pl @@ -15,7 +15,7 @@ :- use_module(library(system)). :- use_module(library(ugraphs)). :- use_module(params). -:- use_module(tptreefile). +:- use_module(tptree_lpad). :- use_module(utility). % :- source. diff --git a/packages/cplint/approx/bestk.pl b/packages/cplint/approx/bestk.pl index 7a47c8fd5..c71f8321f 100644 --- a/packages/cplint/approx/bestk.pl +++ b/packages/cplint/approx/bestk.pl @@ -15,7 +15,7 @@ :- use_module(library(system)). :- use_module(library(ugraphs)). :- use_module(params). -:- use_module(tptreefile). +:- use_module(tptree_lpad). :- use_module(utility). % :- source. diff --git a/packages/cplint/approx/deepdyn.pl b/packages/cplint/approx/deepdyn.pl index 8bdb8b981..ced734864 100644 --- a/packages/cplint/approx/deepdyn.pl +++ b/packages/cplint/approx/deepdyn.pl @@ -15,7 +15,7 @@ :- use_module(library(system)). :- use_module(library(ugraphs)). :- use_module(params). -:- use_module(tptreefile). +:- use_module(tptree_lpad). :- use_module(utility). % :- source. diff --git a/packages/cplint/approx/deepit.pl b/packages/cplint/approx/deepit.pl index 52c71047c..585351aba 100644 --- a/packages/cplint/approx/deepit.pl +++ b/packages/cplint/approx/deepit.pl @@ -15,7 +15,7 @@ :- use_module(library(system)). :- use_module(library(ugraphs)). :- use_module(params). -:- use_module(tptreefile). +:- use_module(tptree_lpad). :- use_module(utility). % :- source. diff --git a/packages/cplint/approx/exact.pl b/packages/cplint/approx/exact.pl index ead21b34c..c7decaa11 100644 --- a/packages/cplint/approx/exact.pl +++ b/packages/cplint/approx/exact.pl @@ -15,7 +15,7 @@ :- use_module(library(system)). :- use_module(library(ugraphs)). :- use_module(params). -:- use_module(tptreefile). +:- use_module(tptree_lpad). :- use_module(utility). % :- source. diff --git a/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c b/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c index 269ae533d..a472d5c8d 100644 --- a/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c +++ b/packages/cplint/approx/simplecuddLPADs/ProblogBDD.c @@ -141,6 +141,13 @@ * The End * * * \******************************************************************************/ +/* modified by Fabrizio Riguzzi in 2009 for dealing with multivalued variables: +instead of variables or their negation, the script can contain equations of the +form +variable=value +Multivalued variables are translated to binary variables by means of a log +encodimg +*/ #include "simplecudd.h" @@ -717,31 +724,17 @@ so that it is not recomputed double value; - //printf("Prob node %d\n",node); - //index=Cudd_NodeReadIndex(node); - //printf("Prob INdex %d\n",index); if (Cudd_IsConstant(node)) { - value=Cudd_V(node);//node->type.value; - //printf("Value %e comp %d\n",value,comp); - if (comp)//Cudd_IsComplement(node)) - //return (1.0-value); - //if (value>0) + value=Cudd_V(node); + if (comp) { -// printf("return 0"); return 0.0; } else { -// printf("return 1"); return 1.0; } -/*else - if (value>0) - return 1.0; - else - return 0.0; -*/ //return value; } else { @@ -749,22 +742,15 @@ so that it is not recomputed if (Found!=NULL) { - //printf("value found %e\n",Found->dvalue); return Found->dvalue; } else { index=Cudd_NodeReadIndex(node); - //printf("node absent %d comp %d\n",node,comp); - //mVarIndex=array_fetch(int,bVar2mVar,index); mVarIndex=MyManager.varmap.bVar2mVar[index]; - //v=array_fetch(variable,vars,mVarIndex); v=MyManager.varmap.mvars[mVarIndex]; nBit=v.nBit; -// printf("calling prob bool mvar %d nbit %d\n",mVarIndex,nBit); - //scanf("%d",&r); res=ProbBool(MyManager,node,0,nBit,0,v,comp); - //printf("New val %e\n",res); AddNode1(MyManager.varmap.bVar2mVar,MyManager.his, MyManager.varmap.varstart, node, res, 0, NULL); return res; } @@ -778,68 +764,40 @@ double ProbBool(extmanager MyManager, DdNode *node, int bits, int nBit,int posBV double p,res; double * probs; int index; -// printf("ProbBool nBit %d\n",nBit); - //scanf("%d",&r); probs=v.probabilities; if (nBit==0) { - //printf("last var bits %d larray %d comp %d\n",bits,array_n(probs),comp); -// printf("bits %d v.nbit %d\n",bits,v.nBit); if (bits>=v.nVal) - //if (comp) { - //printf("bits>=v.nbit return 0\n"); return 0.0; } - //else - //{printf("return 0\n"); - //return 1.0;}} else { - // printf("Val %d\n",bits); - - //p=array_fetch(double,probs,bits); p=probs[bits]; - //printf("prob %e\n",p); res=p*Prob(MyManager,node,comp); - //printf("prob %e\n",p); - //printf("bottom %e\n",res); return res; } } else { - //if (correctPosition(node->index,v,node,posBVar)) index=Cudd_NodeReadIndex(node); - //printf("index %d\n",Cudd_NodeReadIndex(node)); if (correctPosition(index,v,posBVar)) { - //printf("node %d\n",node); - T = Cudd_T(node);//node->type.kids.T; - F = Cudd_E(node);//node->type.kids.E; + T = Cudd_T(node); + F = Cudd_E(node); bits=bits<<1; - //printf("calling on the true child %di complement %d\n",T,Cudd_IsComplement(T)); res=ProbBool(MyManager,T,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res %e\ncalling on the else child %d c %d\n",res,F,Cudd_IsComplement(F)); - //printf("comp %d ",comp); comp=(!comp && Cudd_IsComplement(F)) || (comp && !Cudd_IsComplement(F)); - //printf("comp %d \n",comp); res=res+ ProbBool(MyManager,F,bits,nBit-1,posBVar+1,v,comp); - //printf("res 2 %e\n",res); return res; } else { - //printf("absent var\n"); bits=bits<<1; - // printf("Var =1\n"); res=ProbBool(MyManager,node,bits+1,nBit-1,posBVar+1,v,comp); - //printf("res 1 %e\n",res); -//printf("var =0\n"); res=res+ ProbBool(MyManager,node,bits,nBit-1,posBVar+1,v,comp); - // printf("res 2 %e\n",res); return res; } } @@ -850,12 +808,8 @@ int correctPosition(int index,variable v,int posBVar) currently explored by ProbBool */ { int bvar; -//printf("posbvar %d\n",posBVar); -//printf("length %d\n",array_n(v.booleanVars)); - //bvar=array_fetch(DdNode *,v.booleanVars,posBVar); bvar=v.booleanVars[posBVar]; - // return var->index==index; return(bvar==index); } diff --git a/packages/cplint/approx/simplecuddLPADs/general.c b/packages/cplint/approx/simplecuddLPADs/general.c index 64a7f88e1..fd1d01fb4 100644 --- a/packages/cplint/approx/simplecuddLPADs/general.c +++ b/packages/cplint/approx/simplecuddLPADs/general.c @@ -140,6 +140,11 @@ * The End * * * \******************************************************************************/ +/* modified by Fabrizio Riguzzi in 2009 for dealing with multivalued variables +instead of variables or their negation, the script can contain equations of the +form +variable=value +*/ #include "general.h" diff --git a/packages/cplint/approx/simplecuddLPADs/general.h b/packages/cplint/approx/simplecuddLPADs/general.h index 4441ed623..4411092e4 100644 --- a/packages/cplint/approx/simplecuddLPADs/general.h +++ b/packages/cplint/approx/simplecuddLPADs/general.h @@ -140,6 +140,11 @@ * The End * * * \******************************************************************************/ +/* modified by Fabrizio Riguzzi in 2009 for dealing with multivalued variables +instead of variables or their negation, the script can contain equations of the +form +variable=value +*/ #include diff --git a/packages/cplint/approx/simplecuddLPADs/simplecudd.c b/packages/cplint/approx/simplecuddLPADs/simplecudd.c index e361aeb91..52667ff3c 100644 --- a/packages/cplint/approx/simplecuddLPADs/simplecudd.c +++ b/packages/cplint/approx/simplecuddLPADs/simplecudd.c @@ -140,8 +140,11 @@ * The End * * * \******************************************************************************/ - - +/* modified by Fabrizio Riguzzi in 2009 for dealing with multivalued variables +instead of variables or their negation, the script can contain equations of the +form +variable=value +*/ #include "simplecudd.h" /* BDD manager initialization */ @@ -587,7 +590,6 @@ int LoadMultiVariableData(DdManager * mgr,namedvars varmap, char *filename) { varname = (char *) malloc(sizeof(char) * strlen(dataread)); strcpy(varname, dataread); varmap.vars[index]=varname; - //printf("vname %d %s\n",index, varmap.vars[index]); fscanf(data, "%d\n", &values); varmap.loaded[index] = 1; @@ -767,7 +769,6 @@ int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int * int *booleanVars; char * vname; l=strlen(varname); - //printf("addnamed %s\n",varname); i=0; while (varname[i]!='-') { @@ -776,11 +777,8 @@ int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int * vname=(char *)malloc(sizeof(char)*(l+1)); strncpy(vname,varname,i); vname[i]='\0'; - //printf("addnamed vname %s\n",vname); sscanf(varname+i+1,"%d",value); index= GetNamedVarIndex(varmap, vname); - //printf("index %d\n",index); - //printf("init %d\n",varmap.mvars[index].init); if (index == -1 * varmap.varcnt) { return -1; } else if ((index < 0) || (index == 0 && varmap.vars[0] == NULL)) { @@ -790,16 +788,14 @@ int AddNamedMultiVar(DdManager *mgr,namedvars varmap, const char *varname, int * if (varmap.mvars[index].init==0){ nBit=varmap.mvars[index].nBit; booleanVars= varmap.mvars[index].booleanVars; - //Cudd_MakeTreeNode(mgr,boolVars,nBit,MTR_FIXED); for (i=0;i diff --git a/packages/cplint/approx/tptree_lpad.pl b/packages/cplint/approx/tptree_lpad.pl index d0e724167..d3db013b9 100644 --- a/packages/cplint/approx/tptree_lpad.pl +++ b/packages/cplint/approx/tptree_lpad.pl @@ -6,8 +6,14 @@ % remembers shortest prefix of a conjunction only (i.e. a*b+a*b*c results in a*b only, but b*a+a*b*c is not reduced) % children are sorted, but branches aren't (to speed up search while keeping structure sharing from proof procedure) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +/* derived from tptree.yap from ProbLog by Fabrizio Riguzzi in 2009 +for dealing with multivalued variables +instead of variables or their negation, the script can contain equations of the +form +variable=value +*/ -:- module(ptree,[init_ptree/1, +:- module(ptree_lpad,[init_ptree/1, delete_ptree/1, rename_ptree/2, member_ptree/2,