From 499f2c53687c6bf7bd69254d22b9d65ce7f13ea1 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 17 Mar 2010 07:24:59 +0000 Subject: [PATCH] cleanup: m4 conf and old CLPQR are not used any longer --- CLPQR/CLPQR.LICENSE | 65 - CLPQR/Makefile.in | 153 --- CLPQR/clpq.pl | 78 -- CLPQR/clpq.yap | 78 -- CLPQR/clpq/arith_q.pl | 129 -- CLPQR/clpq/arith_q.yap | 129 -- CLPQR/clpq/class.pl | 112 -- CLPQR/clpq/class.yap | 112 -- CLPQR/clpq/geler.pl | 124 -- CLPQR/clpq/geler.yap | 126 -- CLPQR/clpq/nfq.pl | 76 -- CLPQR/clpq/nfq.yap | 76 -- CLPQR/clpqr/arith.pl | 668 ---------- CLPQR/clpqr/bb.pl | 128 -- CLPQR/clpqr/bb.yap | 132 -- CLPQR/clpqr/bv.pl | 1256 ------------------ CLPQR/clpqr/bv.yap | 1266 ------------------ CLPQR/clpqr/compenv.pl | 86 -- CLPQR/clpqr/dump.pl | 147 --- CLPQR/clpqr/examples/README | 3 - CLPQR/clpqr/examples/SESSION/010 | 66 - CLPQR/clpqr/examples/SESSION/011 | 64 - CLPQR/clpqr/examples/SESSION/012 | 27 - CLPQR/clpqr/examples/SESSION/013 | 138 -- CLPQR/clpqr/examples/SESSION/014 | 25 - CLPQR/clpqr/examples/SESSION/015 | 29 - CLPQR/clpqr/examples/SESSION/016 | 35 - CLPQR/clpqr/examples/SESSION/017 | 53 - CLPQR/clpqr/examples/SESSION/018 | 46 - CLPQR/clpqr/examples/SESSION/019 | 76 -- CLPQR/clpqr/examples/SESSION/020 | 64 - CLPQR/clpqr/examples/SESSION/021 | 55 - CLPQR/clpqr/examples/SESSION/022 | 160 --- CLPQR/clpqr/examples/SESSION/023 | 51 - CLPQR/clpqr/examples/SESSION/024 | 33 - CLPQR/clpqr/examples/SESSION/030 | 27 - CLPQR/clpqr/examples/SESSION/031 | 32 - CLPQR/clpqr/examples/SESSION/032 | 86 -- CLPQR/clpqr/examples/SESSION/033 | 21 - CLPQR/clpqr/examples/SESSION/034 | 52 - CLPQR/clpqr/examples/SESSION/035 | 256 ---- CLPQR/clpqr/examples/SESSION/110 | 66 - CLPQR/clpqr/examples/SESSION/111 | 64 - CLPQR/clpqr/examples/SESSION/112 | 27 - CLPQR/clpqr/examples/SESSION/113 | 138 -- CLPQR/clpqr/examples/SESSION/114 | 25 - CLPQR/clpqr/examples/SESSION/115 | 29 - CLPQR/clpqr/examples/SESSION/116 | 35 - CLPQR/clpqr/examples/SESSION/117 | 53 - CLPQR/clpqr/examples/SESSION/118 | 46 - CLPQR/clpqr/examples/SESSION/119 | 76 -- CLPQR/clpqr/examples/SESSION/120 | 64 - CLPQR/clpqr/examples/SESSION/122 | 160 --- CLPQR/clpqr/examples/SESSION/123 | 51 - CLPQR/clpqr/examples/SESSION/124 | 33 - CLPQR/clpqr/examples/SESSION/130 | 27 - CLPQR/clpqr/examples/SESSION/131 | 32 - CLPQR/clpqr/examples/SESSION/132 | 86 -- CLPQR/clpqr/examples/SESSION/133 | 21 - CLPQR/clpqr/examples/SESSION/134 | 52 - CLPQR/clpqr/examples/SESSION/135 | 256 ---- CLPQR/clpqr/examples/caneghem.pl | 105 -- CLPQR/clpqr/examples/eliminat.pl | 315 ----- CLPQR/clpqr/examples/matmul.pl | 89 -- CLPQR/clpqr/examples/mg.pl | 25 - CLPQR/clpqr/examples/mip.pl | 1826 -------------------------- CLPQR/clpqr/examples/monash/README | 9 - CLPQR/clpqr/examples/monash/air | 129 -- CLPQR/clpqr/examples/monash/amplif | 313 ----- CLPQR/clpqr/examples/monash/complex | 41 - CLPQR/clpqr/examples/monash/critical | 318 ----- CLPQR/clpqr/examples/monash/dnf | 175 --- CLPQR/clpqr/examples/monash/fib | 34 - CLPQR/clpqr/examples/monash/findroot | 60 - CLPQR/clpqr/examples/monash/invert | 93 -- CLPQR/clpqr/examples/monash/laplace | 89 -- CLPQR/clpqr/examples/monash/mortgage | 55 - CLPQR/clpqr/examples/monash/nrev | 30 - CLPQR/clpqr/examples/monash/option | 162 --- CLPQR/clpqr/examples/monash/pictures | 164 --- CLPQR/clpqr/examples/monash/rkf45 | 511 ------- CLPQR/clpqr/examples/monash/rlc | 420 ------ CLPQR/clpqr/examples/monash/smm | 101 -- CLPQR/clpqr/examples/monash/toolpath | 116 -- CLPQR/clpqr/examples/monash/zebra | 62 - CLPQR/clpqr/examples/root.pl | 106 -- CLPQR/clpqr/examples/simplex.pl | 337 ----- CLPQR/clpqr/examples/squares.pl | 108 -- CLPQR/clpqr/expand.pl | 196 --- CLPQR/clpqr/expand.yap | 199 --- CLPQR/clpqr/fourmotz.pl | 294 ----- CLPQR/clpqr/ineq.pl | 984 -------------- CLPQR/clpqr/ineq.yap | 993 -------------- CLPQR/clpqr/itf3.pl | 273 ---- CLPQR/clpqr/monash.pl | 27 - CLPQR/clpqr/nf.pl | 834 ------------ CLPQR/clpqr/nf.yap | 835 ------------ CLPQR/clpqr/ordering.pl | 136 -- CLPQR/clpqr/ordering.yap | 135 -- CLPQR/clpqr/printf.pl | 139 -- CLPQR/clpqr/project.pl | 147 --- CLPQR/clpqr/redund.pl | 157 --- CLPQR/clpqr/store.pl | 279 ---- CLPQR/clpqr/store.yap | 282 ---- CLPQR/clpr.pl | 61 - CLPQR/clpr.yap | 64 - CLPQR/clpr/arith_r.pl | 69 - CLPQR/clpr/arith_r.yap | 69 - CLPQR/clpr/class.pl | 113 -- CLPQR/clpr/class.yap | 114 -- CLPQR/clpr/geler.pl | 124 -- CLPQR/clpr/geler.yap | 128 -- CLPQR/clpr/nf.yap | 835 ------------ CLPQR/clpr/nfr.pl | 76 -- CLPQR/clpr/nfr.yap | 75 -- m4/Atoms.h.m4 | 105 -- m4/Tags_24bits.h.m4 | 83 -- m4/Tags_32LowTag.h.m4 | 92 -- m4/Tags_32Ops.h.m4 | 124 -- m4/Tags_32bits.h.m4 | 79 -- m4/Tags_64bits.h.m4 | 81 -- m4/Tags_64ops.h.m4 | 116 -- m4/TermExt.h.m4 | 267 ---- m4/Yap.h.m4 | 1041 --------------- m4/Yatom.h.m4 | 573 -------- m4/cc_genhdrs.m4 | 10 - m4/gcc_genhdrs.m4 | 47 - m4/gen_ansi.m4 | 228 ---- m4/gen_gcc.m4 | 214 --- m4/gen_linux.m4 | 228 ---- m4/m4.cc | 10 - m4/m4.gcc | 35 - m4/sshift.h.m4 | 116 -- misc/Yap.spec | 6 +- 134 files changed, 3 insertions(+), 24564 deletions(-) delete mode 100644 CLPQR/CLPQR.LICENSE delete mode 100644 CLPQR/Makefile.in delete mode 100644 CLPQR/clpq.pl delete mode 100644 CLPQR/clpq.yap delete mode 100644 CLPQR/clpq/arith_q.pl delete mode 100644 CLPQR/clpq/arith_q.yap delete mode 100644 CLPQR/clpq/class.pl delete mode 100644 CLPQR/clpq/class.yap delete mode 100644 CLPQR/clpq/geler.pl delete mode 100644 CLPQR/clpq/geler.yap delete mode 100644 CLPQR/clpq/nfq.pl delete mode 100644 CLPQR/clpq/nfq.yap delete mode 100644 CLPQR/clpqr/arith.pl delete mode 100644 CLPQR/clpqr/bb.pl delete mode 100644 CLPQR/clpqr/bb.yap delete mode 100644 CLPQR/clpqr/bv.pl delete mode 100644 CLPQR/clpqr/bv.yap delete mode 100644 CLPQR/clpqr/compenv.pl delete mode 100644 CLPQR/clpqr/dump.pl delete mode 100644 CLPQR/clpqr/examples/README delete mode 100644 CLPQR/clpqr/examples/SESSION/010 delete mode 100644 CLPQR/clpqr/examples/SESSION/011 delete mode 100644 CLPQR/clpqr/examples/SESSION/012 delete mode 100644 CLPQR/clpqr/examples/SESSION/013 delete mode 100644 CLPQR/clpqr/examples/SESSION/014 delete mode 100644 CLPQR/clpqr/examples/SESSION/015 delete mode 100644 CLPQR/clpqr/examples/SESSION/016 delete mode 100644 CLPQR/clpqr/examples/SESSION/017 delete mode 100644 CLPQR/clpqr/examples/SESSION/018 delete mode 100644 CLPQR/clpqr/examples/SESSION/019 delete mode 100644 CLPQR/clpqr/examples/SESSION/020 delete mode 100644 CLPQR/clpqr/examples/SESSION/021 delete mode 100644 CLPQR/clpqr/examples/SESSION/022 delete mode 100644 CLPQR/clpqr/examples/SESSION/023 delete mode 100644 CLPQR/clpqr/examples/SESSION/024 delete mode 100644 CLPQR/clpqr/examples/SESSION/030 delete mode 100644 CLPQR/clpqr/examples/SESSION/031 delete mode 100644 CLPQR/clpqr/examples/SESSION/032 delete mode 100644 CLPQR/clpqr/examples/SESSION/033 delete mode 100644 CLPQR/clpqr/examples/SESSION/034 delete mode 100644 CLPQR/clpqr/examples/SESSION/035 delete mode 100644 CLPQR/clpqr/examples/SESSION/110 delete mode 100644 CLPQR/clpqr/examples/SESSION/111 delete mode 100644 CLPQR/clpqr/examples/SESSION/112 delete mode 100644 CLPQR/clpqr/examples/SESSION/113 delete mode 100644 CLPQR/clpqr/examples/SESSION/114 delete mode 100644 CLPQR/clpqr/examples/SESSION/115 delete mode 100644 CLPQR/clpqr/examples/SESSION/116 delete mode 100644 CLPQR/clpqr/examples/SESSION/117 delete mode 100644 CLPQR/clpqr/examples/SESSION/118 delete mode 100644 CLPQR/clpqr/examples/SESSION/119 delete mode 100644 CLPQR/clpqr/examples/SESSION/120 delete mode 100644 CLPQR/clpqr/examples/SESSION/122 delete mode 100644 CLPQR/clpqr/examples/SESSION/123 delete mode 100644 CLPQR/clpqr/examples/SESSION/124 delete mode 100644 CLPQR/clpqr/examples/SESSION/130 delete mode 100644 CLPQR/clpqr/examples/SESSION/131 delete mode 100644 CLPQR/clpqr/examples/SESSION/132 delete mode 100644 CLPQR/clpqr/examples/SESSION/133 delete mode 100644 CLPQR/clpqr/examples/SESSION/134 delete mode 100644 CLPQR/clpqr/examples/SESSION/135 delete mode 100644 CLPQR/clpqr/examples/caneghem.pl delete mode 100644 CLPQR/clpqr/examples/eliminat.pl delete mode 100644 CLPQR/clpqr/examples/matmul.pl delete mode 100644 CLPQR/clpqr/examples/mg.pl delete mode 100644 CLPQR/clpqr/examples/mip.pl delete mode 100644 CLPQR/clpqr/examples/monash/README delete mode 100644 CLPQR/clpqr/examples/monash/air delete mode 100644 CLPQR/clpqr/examples/monash/amplif delete mode 100644 CLPQR/clpqr/examples/monash/complex delete mode 100644 CLPQR/clpqr/examples/monash/critical delete mode 100644 CLPQR/clpqr/examples/monash/dnf delete mode 100644 CLPQR/clpqr/examples/monash/fib delete mode 100644 CLPQR/clpqr/examples/monash/findroot delete mode 100644 CLPQR/clpqr/examples/monash/invert delete mode 100644 CLPQR/clpqr/examples/monash/laplace delete mode 100644 CLPQR/clpqr/examples/monash/mortgage delete mode 100644 CLPQR/clpqr/examples/monash/nrev delete mode 100644 CLPQR/clpqr/examples/monash/option delete mode 100644 CLPQR/clpqr/examples/monash/pictures delete mode 100644 CLPQR/clpqr/examples/monash/rkf45 delete mode 100644 CLPQR/clpqr/examples/monash/rlc delete mode 100644 CLPQR/clpqr/examples/monash/smm delete mode 100644 CLPQR/clpqr/examples/monash/toolpath delete mode 100644 CLPQR/clpqr/examples/monash/zebra delete mode 100644 CLPQR/clpqr/examples/root.pl delete mode 100644 CLPQR/clpqr/examples/simplex.pl delete mode 100644 CLPQR/clpqr/examples/squares.pl delete mode 100644 CLPQR/clpqr/expand.pl delete mode 100644 CLPQR/clpqr/expand.yap delete mode 100644 CLPQR/clpqr/fourmotz.pl delete mode 100644 CLPQR/clpqr/ineq.pl delete mode 100644 CLPQR/clpqr/ineq.yap delete mode 100644 CLPQR/clpqr/itf3.pl delete mode 100644 CLPQR/clpqr/monash.pl delete mode 100644 CLPQR/clpqr/nf.pl delete mode 100644 CLPQR/clpqr/nf.yap delete mode 100644 CLPQR/clpqr/ordering.pl delete mode 100644 CLPQR/clpqr/ordering.yap delete mode 100644 CLPQR/clpqr/printf.pl delete mode 100644 CLPQR/clpqr/project.pl delete mode 100644 CLPQR/clpqr/redund.pl delete mode 100644 CLPQR/clpqr/store.pl delete mode 100644 CLPQR/clpqr/store.yap delete mode 100644 CLPQR/clpr.pl delete mode 100644 CLPQR/clpr.yap delete mode 100644 CLPQR/clpr/arith_r.pl delete mode 100644 CLPQR/clpr/arith_r.yap delete mode 100644 CLPQR/clpr/class.pl delete mode 100644 CLPQR/clpr/class.yap delete mode 100644 CLPQR/clpr/geler.pl delete mode 100644 CLPQR/clpr/geler.yap delete mode 100644 CLPQR/clpr/nf.yap delete mode 100644 CLPQR/clpr/nfr.pl delete mode 100644 CLPQR/clpr/nfr.yap delete mode 100644 m4/Atoms.h.m4 delete mode 100644 m4/Tags_24bits.h.m4 delete mode 100644 m4/Tags_32LowTag.h.m4 delete mode 100644 m4/Tags_32Ops.h.m4 delete mode 100644 m4/Tags_32bits.h.m4 delete mode 100644 m4/Tags_64bits.h.m4 delete mode 100644 m4/Tags_64ops.h.m4 delete mode 100644 m4/TermExt.h.m4 delete mode 100644 m4/Yap.h.m4 delete mode 100644 m4/Yatom.h.m4 delete mode 100644 m4/cc_genhdrs.m4 delete mode 100644 m4/gcc_genhdrs.m4 delete mode 100644 m4/gen_ansi.m4 delete mode 100644 m4/gen_gcc.m4 delete mode 100644 m4/gen_linux.m4 delete mode 100644 m4/m4.cc delete mode 100644 m4/m4.gcc delete mode 100644 m4/sshift.h.m4 diff --git a/CLPQR/CLPQR.LICENSE b/CLPQR/CLPQR.LICENSE deleted file mode 100644 index f31a0dc94..000000000 --- a/CLPQR/CLPQR.LICENSE +++ /dev/null @@ -1,65 +0,0 @@ - -(c) Copyright 1992-2000 -Austrian Research Institute for Artificial Intelligence (OFAI) -Schottengasse 3 -A-1010 Vienna, Austria - - ------------------------------------------------------------------------ - RESEARCH SOFTWARE DISCLAIMER ------------------------------------------- - ------------------------------------------------------------------------ - - As unestablished, research software, this program is provided free of - charge on an "as is" basis without warranty of any kind, either - expressed or implied, including but not limited to implied warranties - of merchantability and fitness for a particular purpose. OFAI does not - warrant that the functions contained in this program will meet the user's - requirements or that the operation of this program will be uninterrupted - or error-free. Acceptance and use of this program constitutes the user's - understanding that he will have no recourse to OFAI for any actual or - consequential damages, including, but not limited to, lost profits or - savings, arising out of the use or inability to use this program. Even - if the user informs OFAI of the possibility of such damages, OFAI expects - the user of this program to accept the risk of any harm arising out of - the use of this program, or the user shall not attempt to use this - program for any purpose. - - ------------------------------------------------------------------------ - USER AGREEMENT --------------------------------------------------------- - ------------------------------------------------------------------------ - - BY ACCEPTANCE AND USE OF THIS EXPERIMENTAL PROGRAM - THE USER AGREES TO THE FOLLOWING: - - a. This program is provided for the user's personal, non-commercial, - experimental use and the user is granted permission to copy this - program to the extent reasonably required for such use. - - b. All title, ownership and rights to this program and any copies - remain with OFAI, irrespective of the ownership of the media on - which the program resides. - - c. The user is permitted to create derivative works to this program. - However, all copies of the program and its derivative works must - contain the OFAI copyright notice, the RESEARCH SOFTWARE - DISCLAIMER and this USER AGREEMENT. - - d. By furnishing this program to the user, OFAI does NOT grant either - directly or by implication, estoppel, or otherwise any license - under any patents, patent applications, trademarks, copyrights or - other rights belonging to OFAI or to any third party, except as - expressly provided herein. - - e. The user understands and agrees that this program and any derivative - works are to be used solely for experimental uses and are not to be - sold, or be commercially exploited in any manner. - - f. OFAI requests that the user supply to OFAI a copy of any changes, - enhancements, or derivative works which the user may create. The - user grants OFAI and its subsidiaries an irrevocable, nonexclusive, - worldwide and royalty-free license to use, execute, reproduce, - display, perform, prepare derivative works based upon, and - distribute, (INTERNALLY AND EXTERNALLY) copies of any and all such - materials and derivative works thereof, and to sublicense others to - do any, some, or all of the foregoing, (including supporting - documentation). - diff --git a/CLPQR/Makefile.in b/CLPQR/Makefile.in deleted file mode 100644 index 27313d4b4..000000000 --- a/CLPQR/Makefile.in +++ /dev/null @@ -1,153 +0,0 @@ -# -# default base directory for YAP installation -# -ROOTDIR = @prefix@ -# -# where the binary should be -# -BINDIR = $(ROOTDIR)/bin -# -# where YAP should look for libraries -# -LIBDIR=@libdir@/Yap -# -# where YAP should look for architecture-independent Prolog libraries -# -SHAREDIR=$(ROOTDIR)/share/Yap -# -# -# You shouldn't need to change what follows. -# -INSTALL=@INSTALL@ -INSTALL_DATA=@INSTALL_DATA@ -INSTALL_PROGRAM=@INSTALL_PROGRAM@ -srcdir=@srcdir@ - -CLPQR_PROGRAMS= $(srcdir)/clpqr/arith.pl \ - $(srcdir)/clpqr/bb.yap \ - $(srcdir)/clpqr/bv.yap \ - $(srcdir)/clpqr/compenv.pl \ - $(srcdir)/clpqr/dump.pl \ - $(srcdir)/clpqr/fourmotz.pl \ - $(srcdir)/clpqr/ineq.yap \ - $(srcdir)/clpqr/itf3.pl \ - $(srcdir)/clpqr/ordering.yap \ - $(srcdir)/clpqr/project.pl \ - $(srcdir)/clpqr/redund.pl \ - $(srcdir)/clpqr/store.yap - -CLPQR_LOCAL= \ - $(srcdir)/clpqr/expand.yap \ - $(srcdir)/clpqr/monash.pl \ - $(srcdir)/clpqr/printf.pl - -CLPR_PROGRAMS= $(srcdir)/clpr/arith_r.yap \ - $(srcdir)/clpr/class.yap\ - $(srcdir)/clpr/geler.yap \ - $(srcdir)/clpr/nf.yap \ - $(srcdir)/clpr/nfr.yap - -CLPQ_PROGRAMS= $(srcdir)/clpq/arith_q.yap \ - $(srcdir)/clpq/class.yap \ - $(srcdir)/clpq/geler.yap \ - $(srcdir)/clpr/nf.yap \ - $(srcdir)/clpq/nfq.yap - -CLPR_TOP= $(srcdir)/clpr.yap - -CLPQ_TOP= $(srcdir)/clpq.yap - -CLPQR_LICENSE= $(srcdir)/CLPQR.LICENSE - -CLPQR_EXAMPLES= $(srcdir)/clpqr/examples/README \ - $(srcdir)/clpqr/examples/caneghem.pl \ - $(srcdir)/clpqr/examples/eliminat.pl \ - $(srcdir)/clpqr/examples/matmul.pl \ - $(srcdir)/clpqr/examples/mg.pl \ - $(srcdir)/clpqr/examples/mip.pl \ - $(srcdir)/clpqr/examples/root.pl \ - $(srcdir)/clpqr/examples/simplex.pl \ - $(srcdir)/clpqr/examples/squares.pl - -CLPQR_EXAMPLES_MONASH= $(srcdir)/clpqr/examples/monash/README \ - $(srcdir)/clpqr/examples/monash/air \ - $(srcdir)/clpqr/examples/monash/amplif \ - $(srcdir)/clpqr/examples/monash/complex \ - $(srcdir)/clpqr/examples/monash/critical \ - $(srcdir)/clpqr/examples/monash/dnf \ - $(srcdir)/clpqr/examples/monash/fib \ - $(srcdir)/clpqr/examples/monash/findroot \ - $(srcdir)/clpqr/examples/monash/invert \ - $(srcdir)/clpqr/examples/monash/laplace \ - $(srcdir)/clpqr/examples/monash/mortgage \ - $(srcdir)/clpqr/examples/monash/nrev \ - $(srcdir)/clpqr/examples/monash/option \ - $(srcdir)/clpqr/examples/monash/pictures \ - $(srcdir)/clpqr/examples/monash/rkf45 \ - $(srcdir)/clpqr/examples/monash/rlc \ - $(srcdir)/clpqr/examples/monash/smm \ - $(srcdir)/clpqr/examples/monash/toolpath \ - $(srcdir)/clpqr/examples/monash/zebra - -CLPQR_EXAMPLES_SESSION= $(srcdir)/clpqr/examples/SESSION/010 \ - $(srcdir)/clpqr/examples/SESSION/011 \ - $(srcdir)/clpqr/examples/SESSION/012 \ - $(srcdir)/clpqr/examples/SESSION/013 \ - $(srcdir)/clpqr/examples/SESSION/014 \ - $(srcdir)/clpqr/examples/SESSION/015 \ - $(srcdir)/clpqr/examples/SESSION/016 \ - $(srcdir)/clpqr/examples/SESSION/017 \ - $(srcdir)/clpqr/examples/SESSION/018 \ - $(srcdir)/clpqr/examples/SESSION/019 \ - $(srcdir)/clpqr/examples/SESSION/020 \ - $(srcdir)/clpqr/examples/SESSION/021 \ - $(srcdir)/clpqr/examples/SESSION/022 \ - $(srcdir)/clpqr/examples/SESSION/023 \ - $(srcdir)/clpqr/examples/SESSION/024 \ - $(srcdir)/clpqr/examples/SESSION/030 \ - $(srcdir)/clpqr/examples/SESSION/031 \ - $(srcdir)/clpqr/examples/SESSION/032 \ - $(srcdir)/clpqr/examples/SESSION/033 \ - $(srcdir)/clpqr/examples/SESSION/034 \ - $(srcdir)/clpqr/examples/SESSION/035 \ - $(srcdir)/clpqr/examples/SESSION/110 \ - $(srcdir)/clpqr/examples/SESSION/111 \ - $(srcdir)/clpqr/examples/SESSION/112 \ - $(srcdir)/clpqr/examples/SESSION/113 \ - $(srcdir)/clpqr/examples/SESSION/114 \ - $(srcdir)/clpqr/examples/SESSION/115 \ - $(srcdir)/clpqr/examples/SESSION/116 \ - $(srcdir)/clpqr/examples/SESSION/117 \ - $(srcdir)/clpqr/examples/SESSION/118 \ - $(srcdir)/clpqr/examples/SESSION/119 \ - $(srcdir)/clpqr/examples/SESSION/120 \ - $(srcdir)/clpqr/examples/SESSION/122 \ - $(srcdir)/clpqr/examples/SESSION/123 \ - $(srcdir)/clpqr/examples/SESSION/124 \ - $(srcdir)/clpqr/examples/SESSION/130 \ - $(srcdir)/clpqr/examples/SESSION/131 \ - $(srcdir)/clpqr/examples/SESSION/132 \ - $(srcdir)/clpqr/examples/SESSION/133 \ - $(srcdir)/clpqr/examples/SESSION/134 \ - $(srcdir)/clpqr/examples/SESSION/135 - -install: $(CLPR_TOP) $(CLPQ_TOP) $(CLPQR_LICENSE) $(CLPQR_PROGRAMS) $(CLPQR_LOCAL)\ - $(CLPQR_EXAMPLES) $(CLPQR_EXAMPLES_MONASH) $(CLPQR_EXAMPLES_SESSION) - mkdir -p $(DESTDIR)$(SHAREDIR)/clpq - mkdir -p $(DESTDIR)$(SHAREDIR)/clpqr - mkdir -p $(DESTDIR)$(SHAREDIR)/clpr - mkdir -p $(DESTDIR)$(SHAREDIR)/clpqr/examples - mkdir -p $(DESTDIR)$(SHAREDIR)/clpqr/examples/SESSION - mkdir -p $(DESTDIR)$(SHAREDIR)/clpqr/examples/monash - for h in $(CLPQ_TOP); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done - for h in $(CLPR_TOP); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done - for h in $(CLPQR_LICENSE); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done - for h in $(CLPQR_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpqr; done - for h in $(CLPQ_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpq; done - for h in $(CLPR_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpr; done - for h in $(CLPQR_LOCAL); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpqr; done - for h in $(CLPQR_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpqr/examples; done - for h in $(CLPQR_EXAMPLES_MONASH); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpqr/examples/monash; done - for h in $(CLPQR_EXAMPLES_SESSION); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpqr/examples/SESSION; done - - diff --git a/CLPQR/clpq.pl b/CLPQR/clpq.pl deleted file mode 100644 index b4d29a515..000000000 --- a/CLPQR/clpq.pl +++ /dev/null @@ -1,78 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: clpq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- module( clpq, [ - {}/1, - maximize/1, - minimize/1, - inf/2, inf/4, sup/2, sup/4, - bb_inf/3, - bb_inf/5, - ordering/1, - entailed/1, - dump/3 - ]). - -:- multifile - user:portray/1, - user:portray_message/2. - -:- dynamic - user:portray/1, - user:portray_message/2. -% -user:portray( rat(A,B)) :- - nonvar( A), % during debugging ... - nonvar( B), - portray_rat( A, B). - -% Must write a space before negative numbers if called e.g. in the -% context of writing F=rat(A,B). -% -portray_rat(A, B) :- - ( A<0, B==1 -> write(' '), write(A) - ; B==1 -> write(A) - ; A<0 -> write(' '), write(A/B) - ; write(A/B) - ). - -% -% Don't report export of private predicates from clpq -% -% -user:portray_message( warning, import(_,_,clpq,private)). - -this_linear_solver( clpq). - -:- use_module( 'clpq/arith_q'). - -:- ensure_loaded( - [ - 'clpq/itf3', - 'clpq/store' % early because of macros - % but after itf3 - ]). - -:- use_module( 'clpq/geler'). -:- use_module( 'clpq/nfq'). -:- use_module( 'clpq/class'). - -:- ensure_loaded( - [ - 'clpq/project', - 'clpq/bv', - 'clpq/ineq', - 'clpq/redund', - 'clpq/fourmotz', - 'clpq/bb', - 'clpq/dump' - ]). diff --git a/CLPQR/clpq.yap b/CLPQR/clpq.yap deleted file mode 100644 index e26c78e06..000000000 --- a/CLPQR/clpq.yap +++ /dev/null @@ -1,78 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: clpq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- module( clpq, [ - {}/1, - maximize/1, - minimize/1, - inf/2, inf/4, sup/2, sup/4, - bb_inf/3, - bb_inf/5, - ordering/1, - entailed/1, - dump/3 - ]). - -:- multifile - user:portray/1, - user:portray_message/2. - -:- dynamic - user:portray/1, - user:portray_message/2. -% -user:portray( rat(A,B)) :- - nonvar( A), % during debugging ... - nonvar( B), - portray_rat( A, B). - -% Must write a space before negative numbers if called e.g. in the -% context of writing F=rat(A,B). -% -portray_rat(A, B) :- - ( A<0, B==1 -> write(' '), write(A) - ; B==1 -> write(A) - ; A<0 -> write(' '), write(A/B) - ; write(A/B) - ). - -% -% Don't report export of private predicates from clpq -% -% -user:portray_message( warning, import(_,_,clpq,private)). - -this_linear_solver( clpq). - -:- use_module( 'clpq/arith_q'). - -:- ensure_loaded( - [ - 'clpqr/itf3', - 'clpqr/store' % early because of macros - % but after itf3 - ]). - -:- use_module( 'clpq/geler'). -:- use_module( 'clpq/nfq'). -:- use_module( 'clpq/class'). - -:- ensure_loaded( - [ - 'clpqr/project', - 'clpqr/bv', - 'clpqr/ineq', - 'clpqr/redund', - 'clpqr/fourmotz', - 'clpqr/bb', - 'clpqr/dump' - ]). diff --git a/CLPQR/clpq/arith_q.pl b/CLPQR/clpq/arith_q.pl deleted file mode 100644 index 03c1520b9..000000000 --- a/CLPQR/clpq/arith_q.pl +++ /dev/null @@ -1,129 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: arith_q.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( arith_q, - [ - arith_eps/1, - arith_normalize/2, - integerp/1, - integerp/2, - % Q specifics - acosq/4, - addq/6, - asinq/4, - atanq/4, - ceilingq/4, - comq/5, - cosq/4, - divq/6, - divq_11/4, - 'divq_-11'/4, - expq/4, - expq/6, - floorq/4, - getq/3, - logq/4, - maxq/6, - minq/6, - mulq/6, - putq/3, - rat_float/3, - roundq/4, - signumq/4, - sinq/4, - subq/6, - tanq/4, - truncateq/4 - ]). - -% -% Modules receiving Q expansion -% -arith_module( clpq). -arith_module( nfq). - -:- multifile - user:goal_expansion/3. - -:- dynamic - user:goal_expansion/3. - -:- discontiguous - user:goal_expansion/3. - -% -user:goal_expansion( putq(D,N,Res), Module, (Res = rat(N,D))) :- arith_module( Module). - -user:goal_expansion( arith_eval(Term,Res), Module, Expansion) :- - arith_module( Module), - compile_Qn( Term, Res, Code), - l2conj( Code, Expansion). - -user:goal_expansion(arith_eval(Rel), Module, Expansion) :- - arith_module( Module), - compile_Qn( Rel, boolean, Code), - l2conj( Code, Expansion). - -user:goal_expansion(case_signum(Term,Lt,Z,Gt), Module, Expansion) :- - arith_module( Module), - compile_case_signum_Qn( Term, Lt,Z,Gt, Code), - l2conj( Code, Expansion). - -:- use_module( arith). - -arith_eps( 0). % for Monash #zero expansion - -arith_normalize( Const, Norm) :- - getq( Const, N, D), - putq( D, N, Norm). - -integerp( rat(_,1)). - -integerp( rat(I,1), I). - -%--------------------------------------------------------------------------- - -user:goal_expansion(comq(Na,Da,Nb,_,S), arith_q, 0 Exp = divq_11(Nb,Db,Nc,Dc) - ; Na==(-1),Da==1 - -> Exp = 'divq_-11'(Nb,Db,Nc,Dc) - ). - -/* - 1 addq(0, 1, 1, 1, _, _). - 10 comq(0, 1, _, _, <). - 1 comq(0, 1, _, _, _). - 16 comq(_, _, 0, 1, <). - 2 comq(_, _, 0, 1, _). - 1 comq(_, _, 1, 1000, <). - 6 comq(_, _, _, _, <). - 7 divq(-1, 1, _, _, _, _). - 1 divq(0, 1, 1, 1, _, _). - 1 divq(1, 1, 1000, 1, _, _). - 4 divq(1, 1, _, _, _, _). - 2 getq(_, -1, 1). - 13 getq(_, 0, 1). - 6 getq(_, 1, 1). - 1 mulq(0, 1, 1000, 1, _, _). - 1 putq(1, 0, _). - 1 putq(1, 1, _). - 1 putq(1000, 1, _). -*/ - diff --git a/CLPQR/clpq/arith_q.yap b/CLPQR/clpq/arith_q.yap deleted file mode 100644 index 38cdd85fb..000000000 --- a/CLPQR/clpq/arith_q.yap +++ /dev/null @@ -1,129 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: arith_q.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( arith_q, - [ - arith_eps/1, - arith_normalize/2, - integerp/1, - integerp/2, - % Q specifics - acosq/4, - addq/6, - asinq/4, - atanq/4, - ceilingq/4, - comq/5, - cosq/4, - divq/6, - divq_11/4, - 'divq_-11'/4, - expq/4, - expq/6, - floorq/4, - getq/3, - logq/4, - maxq/6, - minq/6, - mulq/6, - putq/3, - rat_float/3, - roundq/4, - signumq/4, - sinq/4, - subq/6, - tanq/4, - truncateq/4 - ]). - -% -% Modules receiving Q expansion -% -arith_module( clpq). -arith_module( nfq). - -:- multifile - user:goal_expansion/3. - -:- dynamic - user:goal_expansion/3. - -:- discontiguous - user:goal_expansion/3. - -% -user:goal_expansion( putq(D,N,Res), Module, (Res = rat(N,D))) :- arith_module( Module). - -user:goal_expansion( arith_eval(Term,Res), Module, Expansion) :- - arith_module( Module), - compile_Qn( Term, Res, Code), - l2conj( Code, Expansion). - -user:goal_expansion(arith_eval(Rel), Module, Expansion) :- - arith_module( Module), - compile_Qn( Rel, boolean, Code), - l2conj( Code, Expansion). - -user:goal_expansion(case_signum(Term,Lt,Z,Gt), Module, Expansion) :- - arith_module( Module), - compile_case_signum_Qn( Term, Lt,Z,Gt, Code), - l2conj( Code, Expansion). - -:- use_module( '../clpqr/arith'). - -arith_eps( 0). % for Monash #zero expansion - -arith_normalize( Const, Norm) :- - getq( Const, N, D), - putq( D, N, Norm). - -integerp( rat(_,1)). - -integerp( rat(I,1), I). - -%--------------------------------------------------------------------------- - -user:goal_expansion(comq(Na,Da,Nb,_,S), arith_q, 0 Exp = divq_11(Nb,Db,Nc,Dc) - ; Na==(-1),Da==1 - -> Exp = 'divq_-11'(Nb,Db,Nc,Dc) - ). - -/* - 1 addq(0, 1, 1, 1, _, _). - 10 comq(0, 1, _, _, <). - 1 comq(0, 1, _, _, _). - 16 comq(_, _, 0, 1, <). - 2 comq(_, _, 0, 1, _). - 1 comq(_, _, 1, 1000, <). - 6 comq(_, _, _, _, <). - 7 divq(-1, 1, _, _, _, _). - 1 divq(0, 1, 1, 1, _, _). - 1 divq(1, 1, 1000, 1, _, _). - 4 divq(1, 1, _, _, _, _). - 2 getq(_, -1, 1). - 13 getq(_, 0, 1). - 6 getq(_, 1, 1). - 1 mulq(0, 1, 1000, 1, _, _). - 1 putq(1, 0, _). - 1 putq(1, 1, _). - 1 putq(1000, 1, _). -*/ - diff --git a/CLPQR/clpq/class.pl b/CLPQR/clpq/class.pl deleted file mode 100644 index 3052d218c..000000000 --- a/CLPQR/clpq/class.pl +++ /dev/null @@ -1,112 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: class.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% the class theory -% - -:- module( classq, - [ - class_allvars/2, - class_new/4, - class_drop/2, - class_basis/2, - class_basis_add/3, - class_basis_drop/2, - class_basis_pivot/3, - - ordering/1, - arrangement/2 - ]). - -:- use_module( clpq, '../clpq', [get_or_add_class/2]). - -:- ensure_loaded( ordering). - -:- use_module( library(lists), [append/3]). - -:- use_module( library(atts)). - -:- attribute class_atts/4. - - -verify_attributes( X, Y, []) :- - get_atts( X, class_atts(La,Lat,ABasis,PrioA)), - !, - var( Y), % required - get_atts( Y, class_atts(Lb,Lbt,BBasis,PrioB)), - Lat = Lb, % append - append( ABasis, BBasis, CBasis), - combine( PrioA, PrioB, PrioC), - put_atts( Y, class_atts(La,Lbt,CBasis,PrioC)). -verify_attributes( _, _, []). - -% -% for the debugger -% -% attribute_goal( V, V:A) :- get_atts( V, A), A = [_|_]. - - -% ---------------------------------------------------------------------------------- - -class_new( Class, All,AllT, Basis) :- - put_atts( Su, class_atts(All,AllT,Basis,[])), - Su = Class. - -class_get_prio( Class, Priority) :- - get_atts( Class, class_atts(_,_,_,Priority)). - -class_put_prio( Class, Priority) :- - get_atts( Class, class_atts(All,AllT,Basis,_)), - put_atts( Class, class_atts(All,AllT,Basis,Priority)). - -class_drop( Class, X) :- - get_atts( Class, class_atts(Allvars,Tail,Basis,Priority)), - delete_first( Allvars, X, NewAllvars), - delete_first( Basis, X, NewBasis), - put_atts( Class, class_atts(NewAllvars,Tail,NewBasis,Priority)). - -class_allvars( Class, All) :- get_atts( Class, class_atts(All,_,_,_)). - -class_basis( Class, Basis) :- get_atts( Class, class_atts(_,_,Basis,_)). - -class_basis_add( Class, X, NewBasis) :- - NewBasis = [X|Basis], - get_atts( Class, class_atts(All,AllT,Basis,Priority)), - put_atts( Class, class_atts(All,AllT,NewBasis,Priority)). - -class_basis_drop( Class, X) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, X, Basis), - Basis0 \== Basis, % anything deleted ? - !, - put_atts( Class, class_atts(All,AllT,Basis,Priority)). -class_basis_drop( _, _). - -class_basis_pivot( Class, Enter, Leave) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, Leave, Basis1), - put_atts( Class, class_atts(All,AllT,[Enter|Basis1],Priority)). - -% -% remove the first occurence -% -delete_first( L, _, Res) :- var(L), !, Res = L. -delete_first( [], _, []). -delete_first( [Y|Ys], X, Res) :- - ( X==Y -> - Res = Ys - ; - Res = [Y|Tail], - delete_first( Ys, X, Tail) - ). diff --git a/CLPQR/clpq/class.yap b/CLPQR/clpq/class.yap deleted file mode 100644 index fc749ff18..000000000 --- a/CLPQR/clpq/class.yap +++ /dev/null @@ -1,112 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: class.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% the class theory -% - -:- module( classq, - [ - class_allvars/2, - class_new/4, - class_drop/2, - class_basis/2, - class_basis_add/3, - class_basis_drop/2, - class_basis_pivot/3, - - ordering/1, - arrangement/2 - ]). - -:- use_module( clpq, '../clpq', [get_or_add_class/2]). - -:- ensure_loaded( '../clpqr/ordering'). - -:- use_module( library(lists), [append/3]). - -:- use_module( library(atts)). - -:- attribute class_atts/4. - - -verify_attributes( X, Y, []) :- - get_atts( X, class_atts(La,Lat,ABasis,PrioA)), - !, - var( Y), % required - get_atts( Y, class_atts(Lb,Lbt,BBasis,PrioB)), - Lat = Lb, % append - append( ABasis, BBasis, CBasis), - combine( PrioA, PrioB, PrioC), - put_atts( Y, class_atts(La,Lbt,CBasis,PrioC)). -verify_attributes( _, _, []). - -% -% for the debugger -% -% attribute_goal( V, V:A) :- get_atts( V, A), A = [_|_]. - - -% ---------------------------------------------------------------------------------- - -class_new( Class, All,AllT, Basis) :- - put_atts( Su, class_atts(All,AllT,Basis,[])), - Su = Class. - -class_get_prio( Class, Priority) :- - get_atts( Class, class_atts(_,_,_,Priority)). - -class_put_prio( Class, Priority) :- - get_atts( Class, class_atts(All,AllT,Basis,_)), - put_atts( Class, class_atts(All,AllT,Basis,Priority)). - -class_drop( Class, X) :- - get_atts( Class, class_atts(Allvars,Tail,Basis,Priority)), - delete_first( Allvars, X, NewAllvars), - delete_first( Basis, X, NewBasis), - put_atts( Class, class_atts(NewAllvars,Tail,NewBasis,Priority)). - -class_allvars( Class, All) :- get_atts( Class, class_atts(All,_,_,_)). - -class_basis( Class, Basis) :- get_atts( Class, class_atts(_,_,Basis,_)). - -class_basis_add( Class, X, NewBasis) :- - NewBasis = [X|Basis], - get_atts( Class, class_atts(All,AllT,Basis,Priority)), - put_atts( Class, class_atts(All,AllT,NewBasis,Priority)). - -class_basis_drop( Class, X) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, X, Basis), - Basis0 \== Basis, % anything deleted ? - !, - put_atts( Class, class_atts(All,AllT,Basis,Priority)). -class_basis_drop( _, _). - -class_basis_pivot( Class, Enter, Leave) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, Leave, Basis1), - put_atts( Class, class_atts(All,AllT,[Enter|Basis1],Priority)). - -% -% remove the first occurence -% -delete_first( L, _, Res) :- var(L), !, Res = L. -delete_first( [], _, []). -delete_first( [Y|Ys], X, Res) :- - ( X==Y -> - Res = Ys - ; - Res = [Y|Tail], - delete_first( Ys, X, Tail) - ). diff --git a/CLPQR/clpq/geler.pl b/CLPQR/clpq/geler.pl deleted file mode 100644 index fcab14ad0..000000000 --- a/CLPQR/clpq/geler.pl +++ /dev/null @@ -1,124 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: geler.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( geler_q, - [ - geler/2, - project_nonlin/3, - collect_nonlin/3 - ]). - -:- use_module( library(atts)). - -:- attribute goals/1, all_nonlin/1. - -attribute_goal( X, Goals) :- - get_atts( X, goals(Gs)), - nonexhausted( Gs, Goals, []), - Goals = [_|_]. -attribute_goal( X, Conj) :- - get_atts( X, all_nonlin(Goals)), - l2conj( Goals, Conj). - -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - -nonexhausted( run(Mutex,G)) --> - ( { - var(Mutex) - } -> - [ G ] - ; - [] - ). -nonexhausted( (A,B)) --> - nonexhausted( A), - nonexhausted( B). - -verify_attributes( X, Y, Later) :- - get_atts( X, goals(Gx)), - !, - ( var(Y), - ( get_atts( Y, goals(Gy)) -> - Later = [Gx,Gy], - put_atts( Y, -goals(_)) - ; - Later = [], - put_atts( Y, goals(Gx)) - ) - ; nonvar( Y), - Later = [Gx] - ). -verify_attributes( _, _, []). - -/* -project_attributes( _, Cvas) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - put_atts( _, all_nonlin(Ls)). -*/ - -% -% called from project.pl -% -project_nonlin( _, Cvas, Reachable) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - prolog:term_variables( Ls, Reachable), - put_atts( _, all_nonlin(Ls)). - -collect_nonlin( []) --> []. -collect_nonlin( [X|Xs]) --> - ( {get_atts( X, goals(Gx))} -> - trans( Gx), - collect_nonlin( Xs) - ; - collect_nonlin( Xs) - ). - -trans( (A,B)) --> - trans( A), - trans( B). -trans( run(Mutex,Gs)) --> - ( {var(Mutex)} -> - {Mutex = done}, - transg( Gs) - ; - [] - ). - -transg( (A,B)) --> !, - transg( A), - transg( B). -transg( M:G) --> !, - M:transg( G). -transg( G) --> [ G ]. - -run( Mutex, _) :- nonvar(Mutex). -run( Mutex, G) :- var(Mutex), Mutex=done, call( G). - -:- meta_predicate geler(+,:). -% -geler( Vars, Goal) :- - attach( Vars, run(_Mutex,Goal)). - -attach( [], _). -attach( [V|Vs], Goal) :- - ( var(V), get_atts( V, goals(Gv)) -> - put_atts( V, goals((Goal,Gv))) - ; - put_atts( V, goals(Goal)) - ), - attach( Vs, Goal). diff --git a/CLPQR/clpq/geler.yap b/CLPQR/clpq/geler.yap deleted file mode 100644 index 7ddda9800..000000000 --- a/CLPQR/clpq/geler.yap +++ /dev/null @@ -1,126 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: geler.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( geler_q, - [ - geler/2, - project_nonlin/3, - collect_nonlin/3 - ]). - -:- use_module( library(atts)). -:- use_module( library(terms)). - -:- attribute goals/1, all_nonlin/1. - -attribute_goal( X, Goals) :- - get_atts( X, goals(Gs)), - nonexhausted( Gs, Goals, []), - Goals = [_|_]. -attribute_goal( X, Conj) :- - get_atts( X, all_nonlin(Goals)), - l2conj( Goals, Conj). - -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - -nonexhausted( run(Mutex,G)) --> - ( { - var(Mutex) - } -> - [ G ] - ; - [] - ). -nonexhausted( (A,B)) --> - nonexhausted( A), - nonexhausted( B). - -verify_attributes( X, Y, Later) :- - get_atts( X, goals(Gx)), - !, - ( var(Y), - ( get_atts( Y, goals(Gy)) -> - Later = [Gx,Gy], - put_atts( Y, -goals(_)) - ; - Later = [], - put_atts( Y, goals(Gx)) - ) - ; nonvar( Y), - Later = [Gx] - ). -verify_attributes( _, _, []). - -/* -project_attributes( _, Cvas) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - put_atts( _, all_nonlin(Ls)). -*/ - -% -% called from project.pl -% -project_nonlin( _, Cvas, Reachable) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - term_variables( Ls, Reachable), - put_atts( _, all_nonlin(Ls)). - -collect_nonlin( []) --> []. -collect_nonlin( [X|Xs]) --> - ( {get_atts( X, goals(Gx))} -> - trans( Gx), - collect_nonlin( Xs) - ; - collect_nonlin( Xs) - ). - -trans( (A,B)) --> - trans( A), - trans( B). -trans( run(Mutex,Gs)) --> - ( {var(Mutex)} -> - {Mutex = done}, - transg( Gs) - ; - [] - ). - -transg( (A,B)) --> !, - transg( A), - transg( B). -transg( M:G) --> !, - M:transg( G). -transg( G) --> [ G ]. - -%vsc: added ! (01/06/06) -run( Mutex, _) :- nonvar(Mutex), !. -run( Mutex, G) :- var(Mutex), Mutex=done, call( G). - -:- meta_predicate geler(+,:). -% -geler( Vars, Goal) :- - attach( Vars, run(_Mutex,Goal)). - -attach( [], _). -attach( [V|Vs], Goal) :- - ( var(V), get_atts( V, goals(Gv)) -> - put_atts( V, goals((Goal,Gv))) - ; - put_atts( V, goals(Goal)) - ), - attach( Vs, Goal). diff --git a/CLPQR/clpq/nfq.pl b/CLPQR/clpq/nfq.pl deleted file mode 100644 index 63ffd5b23..000000000 --- a/CLPQR/clpq/nfq.pl +++ /dev/null @@ -1,76 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nfq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( nfq, - [ - {}/1, - entailed/1, - wait_linear/3, - - nf/2, - repair/2, - nf_constant/2, - split/3, - transg/3 - ]). - -:- use_module( arith_q). - -:- use_module( clpq, '../clpq', - [ - 'solve_<'/1, - 'solve_=<'/1, - 'solve_=\='/1, - add_linear_11/3, - export_binding/2, - ineq_one/4, - ineq_one_n_n_0/1, - ineq_one_n_p_0/1, - ineq_one_s_n_0/1, - ineq_one_s_p_0/1, - log_deref/4, - normalize_scalar/2, - solve/1 - ]). - -:- ensure_loaded( nf). - -transg( resubmit_eq(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term=Z} ]. -transg( resubmit_lt(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term= - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term=\=Z} ]. -transg( wait_linear_retry(Nf,Res,Goal)) --> - { - nf2term( Nf, Term) - }, - [ clpq:{Term=Res}, Goal ]. diff --git a/CLPQR/clpq/nfq.yap b/CLPQR/clpq/nfq.yap deleted file mode 100644 index 0cc127099..000000000 --- a/CLPQR/clpq/nfq.yap +++ /dev/null @@ -1,76 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nfq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( nfq, - [ - {}/1, - entailed/1, - wait_linear/3, - - nf/2, - repair/2, - nf_constant/2, - split/3, - transg/3 - ]). - -:- use_module( arith_q). - -:- use_module( clpq, '../clpq', - [ - 'solve_<'/1, - 'solve_=<'/1, - 'solve_=\\='/1, - add_linear_11/3, - export_binding/2, - ineq_one/4, - ineq_one_n_n_0/1, - ineq_one_n_p_0/1, - ineq_one_s_n_0/1, - ineq_one_s_p_0/1, - log_deref/4, - normalize_scalar/2, - solve/1 - ]). - -:- ensure_loaded(nf). - -transg( resubmit_eq(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term=Z} ]. -transg( resubmit_lt(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term= - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpq:{Term=\=Z} ]. -transg( wait_linear_retry(Nf,Res,Goal)) --> - { - nf2term( Nf, Term) - }, - [ clpq:{Term=Res}, Goal ]. diff --git a/CLPQR/clpqr/arith.pl b/CLPQR/clpqr/arith.pl deleted file mode 100644 index d30d4380f..000000000 --- a/CLPQR/clpqr/arith.pl +++ /dev/null @@ -1,668 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: arith.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% common code for R,Q, runtime predicates -% -% linearize evaluation, collect vars -% -% Todo: +) limited encoding length option -% +) 2 stage compilation: a) linearization -% b) specialization to R or Q -% -% - -l2conj( [], true). -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - -% ---------------------------------------------------------------------- - -% -% float/1 coercion is allowed only at the outermost level in Q -% -compile_Q( Term, R, Code) :- - linearize( Term, Res, Linear), - specialize_Q( Linear, Code, Ct), - ( Res = boolean, Ct = [] - ; Res = float(R), Ct = [] - ; Res = rat(N,D), Ct = [ putq(D,N,R) ] - ). - -% -% assumes normalized params and puts a normalized result -% -compile_Qn( Term, R, Code) :- - linearize( Term, Res, Linear), - specialize_Qn( Linear, Code, Ct), - ( Res = boolean, Ct = [] - ; Res = float(R), Ct = [] - ; Res = rat(N,D), Ct = [ putq(D,N,R) ] - ). - - -compile_case_signum_Qn( Term, Lt,Z,Gt, Code) :- - linearize( Term, rat(N,_), Linear), - specialize_Qn( Linear, Code, - [ - compare( Rel, N, 0), - ( Rel = <, Lt - ; Rel = =, Z - ; Rel = >, Gt - ) - ]). - - -specialize_Qn( []) --> []. -specialize_Qn( [Op|Ops]) --> - specialize_Qn( Op), - specialize_Qn( Ops). -% -specialize_Qn( op_var(rat(N,D),Var)) --> [ Var=rat(N,D) ]. % <--- here is the difference --- -specialize_Qn( op_integer(rat(I,1),I)) --> []. -specialize_Qn( op_rat(rat(N,D),N,D)) --> []. -specialize_Qn( op_float(rat(N,D),X)) --> [], { float_rat( X, N,D) }. -specialize_Qn( apply(R,Func)) --> - specialize_Q_fn( Func, R). - - -specialize_Q( []) --> []. -specialize_Q( [Op|Ops]) --> - specialize_Q( Op), - specialize_Q( Ops). -% -specialize_Q( op_var(rat(N,D),Var)) --> [ getq(Var,N,D) ]. -specialize_Q( op_integer(rat(I,1),I)) --> []. -specialize_Q( op_rat(rat(N,D),N,D)) --> [], { D > 0 }. -specialize_Q( op_float(rat(N,D),X)) --> [], { float_rat( X, N,D) }. -specialize_Q( apply(R,Func)) --> - specialize_Q_fn( Func, R). - -specialize_Q_fn( +rat(N,D), rat(N,D)) --> []. -specialize_Q_fn( numer(rat(N,_)), rat(N,1)) --> []. -specialize_Q_fn( denom(rat(_,D)), rat(D,1)) --> []. -specialize_Q_fn( -rat(N0,D), rat(N,D)) --> [ N is -N0 ]. -specialize_Q_fn( abs(rat(Nx,Dx)), rat(N,D)) --> [ N is abs(Nx) ], {D=Dx}. -specialize_Q_fn( signum(rat(Nx,Dx)), rat(N,D)) --> [ signumq( Nx,Dx, N,D) ]. -specialize_Q_fn( floor(rat(Nx,Dx)), rat(N,D)) --> [ floorq( Nx,Dx, N,D) ]. -specialize_Q_fn( ceiling(rat(Nx,Dx)), rat(N,D)) --> [ ceilingq( Nx,Dx, N,D) ]. -specialize_Q_fn( truncate(rat(Nx,Dx)), rat(N,D)) --> [ truncateq( Nx,Dx, N,D) ]. -specialize_Q_fn( round(rat(Nx,Dx)), rat(N,D)) --> [ roundq( Nx,Dx, N,D) ]. -specialize_Q_fn( log(rat(Nx,Dx)), rat(N,D)) --> [ logq( Nx,Dx, N,D) ]. -specialize_Q_fn( exp(rat(Nx,Dx)), rat(N,D)) --> [ expq( Nx,Dx, N,D) ]. -specialize_Q_fn( sin(rat(Nx,Dx)), rat(N,D)) --> [ sinq( Nx,Dx, N,D) ]. -specialize_Q_fn( cos(rat(Nx,Dx)), rat(N,D)) --> [ cosq( Nx,Dx, N,D) ]. -specialize_Q_fn( tan(rat(Nx,Dx)), rat(N,D)) --> [ tanq( Nx,Dx, N,D) ]. -specialize_Q_fn( asin(rat(Nx,Dx)), rat(N,D)) --> [ asinq( Nx,Dx, N,D) ]. -specialize_Q_fn( acos(rat(Nx,Dx)), rat(N,D)) --> [ acosq( Nx,Dx, N,D) ]. -specialize_Q_fn( atan(rat(Nx,Dx)), rat(N,D)) --> [ atanq( Nx,Dx, N,D) ]. -specialize_Q_fn( float(rat(Nx,Dx)), float(F)) --> [ rat_float( Nx,Dx, F) ]. -% -specialize_Q_fn( rat(Nx,Dx)+rat(Ny,Dy), rat(N,D)) --> [ addq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( rat(Nx,Dx)-rat(Ny,Dy), rat(N,D)) --> [ subq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( rat(Nx,Dx)*rat(Ny,Dy), rat(N,D)) --> [ mulq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( rat(Nx,Dx)/rat(Ny,Dy), rat(N,D)) --> [ divq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( exp(rat(Nx,Dx),rat(Ny,Dy)), rat(N,D)) --> [ expq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( min(rat(Nx,Dx),rat(Ny,Dy)), rat(N,D)) --> [ minq( Nx,Dx, Ny,Dy, N,D) ]. -specialize_Q_fn( max(rat(Nx,Dx),rat(Ny,Dy)), rat(N,D)) --> [ maxq( Nx,Dx, Ny,Dy, N,D) ]. -% -specialize_Q_fn( rat(Nx,Dx) < rat(Ny,Dy), boolean) --> [ comq( Nx,Dx, Ny,Dy, <) ]. -specialize_Q_fn( rat(Nx,Dx) > rat(Ny,Dy), boolean) --> [ comq( Ny,Dy, Nx,Dx, <) ]. -specialize_Q_fn( rat(Nx,Dx) =< rat(Ny,Dy), boolean) --> [ comq( Nx,Dx, Ny,Dy, Rel), Rel \== (>) ]. -specialize_Q_fn( rat(Nx,Dx) >= rat(Ny,Dy), boolean) --> [ comq( Ny,Dy, Nx,Dx, Rel), Rel \== (>) ]. -specialize_Q_fn( rat(Nx,Dx) =\= rat(Ny,Dy), boolean) --> [ comq( Nx,Dx, Ny,Dy, Rel), Rel \== (=) ]. -specialize_Q_fn( rat(Nx,Dx) =:= rat(Ny,Dy), boolean) --> - % - % *normalized* rationals - % - ( {Nx = Ny} -> [] ; [ Nx = Ny ] ), - ( {Dx = Dy} -> [] ; [ Dx = Dy ] ). - -% ---------------------------------------------------------------------- - -compile_R( Term, R, Code) :- - linearize( Term, Res, Linear), - specialize_R( Linear, Code, Ct), - ( Res == boolean -> - Ct = [], R = boolean - ; float(Res) -> - Ct = [ R=Res ] - ; - Ct = [ R is Res ] - ). - -compile_case_signum_R( Term, Lt,Z,Gt, Code) :- - eps( Eps, NegEps), - linearize( Term, Res, Linear), - specialize_R( Linear, Code, - [ - Rv is Res, - ( Rv < NegEps -> Lt - ; Rv > Eps -> Gt - ; Z - ) - ]). - -specialize_R( []) --> []. -specialize_R( [Op|Ops]) --> - specialize_R( Op), - specialize_R( Ops). -% -specialize_R( op_var(Var,Var)) --> []. -specialize_R( op_integer(R,I)) --> [], { R is float(I) }. -specialize_R( op_rat(R,N,D)) --> [], { rat_float( N,D, R) }. -specialize_R( op_float(F,F)) --> []. -specialize_R( apply(R,Func)) --> - specialize_R_fn( Func, R). - -specialize_R_fn( signum(X), S) --> - ( {var(X)} -> - {Xe=X} - ; - [ Xe is X ] - ), - { - eps( Eps, NegEps) - }, - [ - ( Xe < NegEps -> S = -1.0 - ; Xe > Eps -> S = 1.0 - ; S = 0.0 - ) - ]. - -specialize_R_fn( +X, X) --> []. -specialize_R_fn( -X, -X) --> []. -specialize_R_fn( abs(X), abs(X)) --> []. -specialize_R_fn( floor(X), float(floor(/*float?*/X))) --> []. -specialize_R_fn( ceiling(X), float(ceiling(/*float?*/X))) --> []. -specialize_R_fn( truncate(X), float(truncate(/*float?*/X))) --> []. -specialize_R_fn( round(X), float(round(/*float?*/X))) --> []. -specialize_R_fn( log(X), log(X)) --> []. -specialize_R_fn( exp(X), exp(X)) --> []. -specialize_R_fn( sin(X), sin(X)) --> []. -specialize_R_fn( cos(X), cos(X)) --> []. -specialize_R_fn( tan(X), tan(X)) --> []. -specialize_R_fn( asin(X), asin(X)) --> []. -specialize_R_fn( acos(X), acos(X)) --> []. -specialize_R_fn( atan(X), atan(X)) --> []. -specialize_R_fn( float(X), float(X)) --> []. -% -specialize_R_fn( X+Y, X+Y) --> []. -specialize_R_fn( X-Y, X-Y) --> []. -specialize_R_fn( X*Y, X*Y) --> []. -specialize_R_fn( X/Y, X/Y) --> []. -specialize_R_fn( exp(X,Y), exp(X,Y)) --> []. -specialize_R_fn( min(X,Y), min(X,Y)) --> []. -specialize_R_fn( max(X,Y), max(X,Y)) --> []. -/**/ -% -% An absolute eps is of course not very meaningful. -% An eps scaled by the magnitude of the operands participating -% in the comparison is too expensive to support in Prolog on the -% other hand ... -% -% -% -eps 0 +eps -% ---------------[----|----]---------------- -% < 0 > 0 -% <-----------] [-----------> -% =< 0 -% <---------------------] -% >= 0 -% [---------------------> -% -% -specialize_R_fn( X < Y, boolean) --> - { - eps( Eps, NegEps) - }, - ( {X==0} -> - [ Y > Eps ] - ; {Y==0} -> - [ X < NegEps ] - ; - [ X-Y < NegEps ] - ). -specialize_R_fn( X > Y, boolean) --> specialize_R_fn( Y < X, boolean). -specialize_R_fn( X =< Y, boolean) --> - { - eps( Eps, _) - }, - [ X-Y < Eps ]. -specialize_R_fn( X >= Y, boolean) --> specialize_R_fn( Y =< X, boolean). -specialize_R_fn( X =:= Y, boolean) --> - { - eps( Eps, NegEps) - }, - ( {X==0} -> - [ Y >= NegEps, Y =< Eps ] - ; {Y==0} -> - [ X >= NegEps, X =< Eps ] - ; - [ - Diff is X-Y, - Diff =< Eps, - Diff >= NegEps - ] - ). -specialize_R_fn( X =\= Y, boolean) --> - { - eps( Eps, NegEps) - }, - [ - Diff is X-Y, - ( Diff < NegEps -> true ; Diff > Eps ) - ]. -/**/ - -/** -% -% b30427, pp.218 -% -specialize_R_fn( X > Y, boolean) --> specialize_R_fn( Y < X, boolean). -specialize_R_fn( X < Y, boolean) --> - [ scaled_eps(X,Y,E), Y-X > E ]. - -specialize_R_fn( X >= Y, boolean) --> specialize_R_fn( Y =< X, boolean). -specialize_R_fn( X =< Y, boolean) --> - [ scaled_eps(X,Y,E), X-Y =< E ]. % \+ > - -specialize_R_fn( X =:= Y, boolean) --> - [ scaled_eps(X,Y,E), abs(X-Y) =< E ]. - -specialize_R_fn( X =\= Y, boolean) --> - [ scaled_eps(X,Y,E), abs(X-Y) > E ]. - - -scaled_eps( X, Y, Eps) :- - exponent( X, Ex), - exponent( Y, Ey), - arith_eps( E), - Max is max(Ex,Ey), - ( Max < 0 -> - Eps is E/(1< {var(X)}, !, [ ]. -linearize( X, R, Vs,Vs) --> {integer(X)}, !, [ op_integer(R,X) ]. -linearize( X, R, Vs,Vs) --> {float(X)}, !, [ op_float(R,X) ]. -linearize( rat(N,D), R, Vs,Vs) --> !, [ op_rat(R,N,D) ]. -linearize( Term, R, V0,V1) --> - { - functor( Term, N, A), - functor( Skeleton, N, A) - }, - linearize_args( A, Term, Skeleton, V0,V1), [ apply(R,Skeleton) ]. - -linearize_args( 0, _, _, Vs,Vs) --> []. -linearize_args( N, T, S, V0,V2) --> - { - arg( N, T, Arg), - arg( N, S, Res), - N1 is N-1 - }, - linearize( Arg, Res, V0,V1), - linearize_args( N1, T, S, V1,V2). - -join_vars( [], Y-Ry) --> [ op_var(Ry,Y) ]. -join_vars( [X-Rx|Xs], Y-Ry) --> - ( {X==Y} -> - {Rx=Ry}, - join_vars( Xs, Y-Ry) - ; - [ op_var(Ry,Y) ], - join_vars( Xs, X-Rx) - ). - -% ---------------------------------- runtime system --------------------------- - -% -% C candidate -% -limit_encoding_length( 0,D, _, 0,D) :- !. % msb ... -limit_encoding_length( N,D, Bits, Nl,Dl) :- - Shift is min(max(msb(abs(N)),msb(D))-Bits, - min(msb(abs(N)),msb(D))), - Shift > 0, - !, - Ns is N>>Shift, - Ds is D>>Shift, - Gcd is gcd(Ns,Ds), - Nl is Ns//Gcd, - Dl is Ds//Gcd. -limit_encoding_length( N,D, _, N,D). - - -% -% No longer backconvert to integer -% -% putq( 1, N, N) :- !. -putq( D, N, rat(N,D)). - -getq( Exp, N,D) :- var( Exp), !, - raise_exception( instantiation_error(getq(Exp,N,D),1)). -getq( I, I,1) :- integer(I), !. -getq( F, N,D) :- float( F), !, float_rat( F, N,D). -getq( rat(N,D), N,D) :- - integer( N), - integer( D), - D > 0, - 1 =:= gcd(N,D). - -% -% actually just a joke to have this stuff in Q ... -% - expq( N,D, N1,D1) :- rat_float( N,D, X), F is exp(X), float_rat( F, N1,D1). - logq( N,D, N1,D1) :- rat_float( N,D, X), F is log(X), float_rat( F, N1,D1). - sinq( N,D, N1,D1) :- rat_float( N,D, X), F is sin(X), float_rat( F, N1,D1). - cosq( N,D, N1,D1) :- rat_float( N,D, X), F is cos(X), float_rat( F, N1,D1). - tanq( N,D, N1,D1) :- rat_float( N,D, X), F is tan(X), float_rat( F, N1,D1). -asinq( N,D, N1,D1) :- rat_float( N,D, X), F is asin(X), float_rat( F, N1,D1). -acosq( N,D, N1,D1) :- rat_float( N,D, X), F is acos(X), float_rat( F, N1,D1). -atanq( N,D, N1,D1) :- rat_float( N,D, X), F is atan(X), float_rat( F, N1,D1). - -% -% for integer powers we can do it in Q -% -expq( Nx,Dx, Ny,Dy, N,D) :- - ( Dy =:= 1 -> - ( Ny >= 0 -> - powq( Ny, Nx,Dx, 1,1, N,D) - ; - Nabs is -Ny, - powq( Nabs, Nx,Dx, 1,1, N1,D1), - ( N1 < 0 -> - N is -D1, D is -N1 - ; - N = D1, D = N1 - ) - ) - ; - rat_float( Nx,Dx, Fx), - rat_float( Ny,Dy, Fy), - F is exp(Fx,Fy), - float_rat( F, N, D) - ). - -% -% positive integer powers of rational -% -powq( 0, _, _, Nt,Dt, Nt,Dt) :- !. -powq( 1, Nx,Dx, Nt,Dt, Nr,Dr) :- !, mulq( Nx,Dx, Nt,Dt, Nr,Dr). -powq( N, Nx,Dx, Nt,Dt, Nr,Dr) :- - N1 is N >> 1, - ( N /\ 1 =:= 0 -> - Nt1 = Nt, Dt1 = Dt - ; - mulq( Nx,Dx, Nt,Dt, Nt1,Dt1) - ), - mulq( Nx,Dx, Nx,Dx, Nxx,Dxx), - powq( N1, Nxx,Dxx, Nt1,Dt1, Nr,Dr). - - -/* -% -% the choicepoint ruins the party ... -% -mulq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Na,Db), - ( Gcd1 =:= 1 -> Na1=Na,Db1=Db; Na1 is Na//Gcd1,Db1 is Db//Gcd1 ), - Gcd2 is gcd(Nb,Da), - ( Gcd2 =:= 1 -> Nb1=Nb,Da1=Da; Nb1 is Nb//Gcd2,Da1 is Da//Gcd2 ), - Nc is Na1 * Nb1, - Dc is Da1 * Db1. -*/ -mulq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Na,Db), - Na1 is Na//Gcd1, - Db1 is Db//Gcd1, - Gcd2 is gcd(Nb,Da), - Nb1 is Nb//Gcd2, - Da1 is Da//Gcd2, - Nc is Na1 * Nb1, - Dc is Da1 * Db1. - -/* -divq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Na,Nb), - ( Gcd1 =:= 1 -> Na1=Na,Nb1=Nb; Na1 is Na//Gcd1,Nb1 is Nb//Gcd1 ), - Gcd2 is gcd(Da,Db), - ( Gcd2 =:= 1 -> Da1=Da,Db1=Db; Da1 is Da//Gcd2,Db1 is Db//Gcd2 ), - ( Nb1 < 0 -> % keep denom positive !!! - Nc is -(Na1 * Db1), - Dc is Da1 * (-Nb1) - ; - Nc is Na1 * Db1, - Dc is Da1 * Nb1 - ). -*/ -divq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Na,Nb), - Na1 is Na//Gcd1, - Nb1 is Nb//Gcd1, - Gcd2 is gcd(Da,Db), - Da1 is Da//Gcd2, - Db1 is Db//Gcd2, - ( Nb1 < 0 -> % keep denom positive !!! - Nc is -(Na1 * Db1), - Dc is Da1 * (-Nb1) - ; - Nc is Na1 * Db1, - Dc is Da1 * Nb1 - ). - -% -% divq_11( Nb,Db, Nc,Dc) :- divq( 1,1, Nb,Db, Nc,Dc). -% -divq_11( Nb,Db, Nc,Dc) :- - ( Nb < 0 -> % keep denom positive !!! - Nc is -Db, - Dc is -Nb - ; - Nc is Db, - Dc is Nb - ). - -'divq_-11'( Nb,Db, Nc,Dc) :- - ( Nb < 0 -> % keep denom positive !!! - Nc is Db, - Dc is -Nb - ; - Nc is -Db, - Dc is Nb - ). - -/* -addq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Da,Db), - ( Gcd1 =:= 1 -> % This is the case (for random input) with - % probability 6/(pi**2). - Nc is Na*Db + Nb*Da, - Dc is Da*Db - ; - T is Na*(Db//Gcd1) + Nb*(Da//Gcd1), - Gcd2 is gcd(T,Gcd1), - Nc is T//Gcd2, - Dc is (Da//Gcd1) * (Db//Gcd2) - ). -*/ -addq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Da,Db), - T is Na*(Db//Gcd1) + Nb*(Da//Gcd1), - Gcd2 is gcd(T,Gcd1), - Nc is T//Gcd2, - Dc is (Da//Gcd1) * (Db//Gcd2). - -/* -subq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Da,Db), - ( Gcd1 =:= 1 -> % This is the case (for random input) with - % probability 6/(pi**2). - Nc is Na*Db - Nb*Da, - Dc is Da*Db - ; - T is Na*(Db//Gcd1) - Nb*(Da//Gcd1), - Gcd2 is gcd(T,Gcd1), - Nc is T//Gcd2, - Dc is (Da//Gcd1) * (Db//Gcd2) - ). -*/ -subq( Na,Da, Nb,Db, Nc,Dc) :- - Gcd1 is gcd(Da,Db), - T is Na*(Db//Gcd1) - Nb*(Da//Gcd1), - Gcd2 is gcd(T,Gcd1), - Nc is T//Gcd2, - Dc is (Da//Gcd1) * (Db//Gcd2). - -comq( Na,Da, Nb,Db, S) :- % todo: avoid multiplication by looking a signs first !!! - Xa is Na * Db, - Xb is Nb * Da, - compare( S, Xa, Xb). - -minq( Na,Da, Nb,Db, N,D) :- - comq( Na,Da, Nb,Db, Rel), - ( Rel = =, N=Na, D=Da - ; Rel = <, N=Na, D=Da - ; Rel = >, N=Nb, D=Db - ). - -maxq( Na,Da, Nb,Db, N,D) :- - comq( Na,Da, Nb,Db, Rel), - ( Rel = =, N=Nb, D=Db - ; Rel = <, N=Nb, D=Db - ; Rel = >, N=Na, D=Da - ). - -signumq( N,_, S,1) :- - compare( Rel, N, 0), - rel2sig( Rel, S). - -rel2sig( <, -1). -rel2sig( >, 1). -rel2sig( =, 0). - - - -% ----------------------------------------------------------------------------- - -truncateq( N,D, R,1) :- - R is N // D. - -% -% returns the greatest integral value less than or -% equal to x. This corresponds to IEEE rounding toward nega- -% tive infinity -% -floorq( N,1, N,1) :- !. -floorq( N,D, R,1) :- - ( N < 0 -> - R is N // D - 1 - ; - R is N // D - ). - -% -% returns the least integral value greater than or -% equal to x. This corresponds to IEEE rounding toward posi- -% tive infinity -% -ceilingq( N,1, N,1) :- !. -ceilingq( N,D, R,1) :- - ( N > 0 -> - R is N // D + 1 - ; - R is N // D - ). - -% -% rounding towards zero -% -roundq( N,D, R,1) :- - % rat_float( N,D, F), % cheating, can do that in Q - % R is integer(round(F)). - I is N//D, - subq( N,D, I,1, Rn,Rd), - Rna is abs(Rn), - ( comq( Rna,Rd, 1,2, <) -> - R = I - ; I >= 0 -> - R is I+1 - ; - R is I-1 - ). - -% ------------------------------- rational -> float ------------------------------- -% -% The problem here is that SICStus converts BIG fractions N/D into +-nan -% if it does not fit into a float -% -% | ?- X is msb(integer(1.0e+308)). -% X = 1023 -% - -rat_float( Nx,Dx, F) :- - limit_encoding_length( Nx,Dx, 1023, Nxl,Dxl), - F is Nxl / Dxl. - -% ------------------------------- float -> rational ------------------------------- - -float_rat( F, N, D) :- - float_rat( 100, F, F, 1,0,0,1, N0,D0), % at most 100 iterations - ( D0 < 0 -> % sign normalization - D is -D0, - N is -N0 - ; - D = D0, - N = N0 - ). - -float_rat( 0, _, _, Na,_,Da,_, Na,Da) :- !. -float_rat( _, _, X, Na,_,Da,_, Na,Da) :- - 0.0 =:= abs(X-Na/Da), - !. -float_rat( N, F, X, Na,Nb,Da,Db, Nar,Dar) :- - I is integer(F), - ( I =:= F -> % guard against zero division - Nar is Na*I+Nb, % 1.0 -> 1/1 and not 0/1 (first iter.) !!! - Dar is Da*I+Db - ; - Na1 is Na*I+Nb, - Da1 is Da*I+Db, - F1 is 1/(F-I), - N1 is N-1, - float_rat( N1, F1, X, Na1,Na,Da1,Da, Nar,Dar) - ). - diff --git a/CLPQR/clpqr/bb.pl b/CLPQR/clpqr/bb.pl deleted file mode 100644 index 8ccfd93d2..000000000 --- a/CLPQR/clpqr/bb.pl +++ /dev/null @@ -1,128 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: bb.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -bb_inf( Is, Term, Inf) :- - bb_inf( Is, Term, Inf, _, 0.001). - -bb_inf( Is, Term, Inf, Vertex, Eps) :- - nf( Eps, ENf), - nf_constant( ENf, EpsN), - wait_linear( Term, Nf, bb_inf_internal(Is,Nf,EpsN,Inf,Vertex)). - -% --------------------------------------------------------------------- - -bb_inf_internal( Is, Lin, Eps, _, _) :- - bb_intern( Is, IsNf), - ( bb_delete( incumbent, _) -> true ; true ), - repair( Lin, LinR), % bb_narrow ... - deref( LinR, Lind), - var_with_def_assign( Dep, Lind), - determine_active_dec( Lind), - bb_loop( Dep, IsNf, Eps), - fail. -bb_inf_internal( _, _, _, Inf, Vertex) :- - bb_delete( incumbent, InfVal-Vertex), % GC - { Inf =:= InfVal }. - -bb_loop( Opt, Is, Eps) :- - bb_reoptimize( Opt, Inf), - bb_better_bound( Inf), - vertex_value( Is, Ivs), - ( bb_first_nonint( Is, Ivs, Eps, Viol, Floor, Ceiling) -> - bb_branch( Viol, Floor, Ceiling), - bb_loop( Opt, Is, Eps) - ; - round_values( Ivs, RoundVertex), - % print( incumbent( Inf-RoundVertex)), nl, - bb_put( incumbent, Inf-RoundVertex) - ). - -% -% added ineqs may have led to binding -% -bb_reoptimize( Obj, Inf) :- var( Obj), iterate_dec( Obj, Inf). -bb_reoptimize( Obj, Inf) :- nonvar( Obj), Inf = Obj. - -bb_better_bound( Inf) :- - bb_get( incumbent, Inc-_), - !, - arith_eval( Inf < Inc). -bb_better_bound( _). - -bb_branch( V, U, _) :- { V =< U }. -bb_branch( V, _, L) :- { V >= L }. - -vertex_value( [], []). -vertex_value( [X|Xs], [V|Vs]) :- - rhs_value( X, V), - vertex_value( Xs, Vs). - -rhs_value( Xn, Value) :- nonvar(Xn), Value=Xn. -rhs_value( Xn, Value) :- var(Xn), - deref_var( Xn, Xd), - decompose( Xd, _, R, I), - arith_eval( R+I, Value). - -% -% Need only one as we branch on the first anyway ... -% -bb_first_nonint( [I|Is], [Rhs|Rhss], Eps, Viol, F, C) :- - ( arith_eval( floor(Rhs), Floor), - arith_eval( ceiling(Rhs), Ceiling), - arith_eval(min(Rhs-Floor,Ceiling-Rhs) > Eps) -> - Viol = I, - F = Floor, - C = Ceiling - ; - bb_first_nonint( Is, Rhss, Eps, Viol, F, C) - ). - -round_values( [], []). -round_values( [X|Xs], [Y|Ys]) :- - arith_eval( round(X), Y), - round_values( Xs, Ys). - -bb_intern( [], []). -bb_intern( [X|Xs], [Xi|Xis]) :- - nf( X, Xnf), - bb_intern( Xnf, Xi, X), - bb_intern( Xs, Xis). - -% -% allow more general expressions and conditions? integral(Exp) ??? -% -bb_intern( [], X, _) :- !, arith_eval( 0, X). -bb_intern( [v(I,[])], X, _) :- !, X=I. -bb_intern( [v(One,[X^1])], X, _) :- - arith_eval(One=:=1), - !, - get_atts( X, [type(T),strictness(S)]), - bb_narrow( T, S, X). -bb_intern( _, _, Term) :- - raise_exception( instantiation_error(bb_inf(Term,_,_),1)). - -bb_narrow( t_l(L), S, V) :- - S /\ 2'10 =\= 0, - !, - arith_eval( floor(1+L), B), - { V >= B }. -bb_narrow( t_u(U), S, V) :- - S /\ 2'01 =\= 0, - !, - arith_eval( ceiling(U-1), B), - { V =< B }. -bb_narrow( t_lu(L,U), S, V) :- !, - bb_narrow( t_l(L), S, V), - bb_narrow( t_u(U), S, V). -bb_narrow( _, _, _). - diff --git a/CLPQR/clpqr/bb.yap b/CLPQR/clpqr/bb.yap deleted file mode 100644 index 7ef330b7d..000000000 --- a/CLPQR/clpqr/bb.yap +++ /dev/null @@ -1,132 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: bb.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -bb_inf( Is, Term, Inf) :- - bb_inf( Is, Term, Inf, _, 0.001). - -bb_inf( Is, Term, Inf, Vertex, Eps) :- - nf( Eps, ENf), - nf_constant( ENf, EpsN), - wait_linear( Term, Nf, bb_inf_internal(Is,Nf,EpsN,Inf,Vertex)). - -% --------------------------------------------------------------------- - -bb_inf_internal( Is, Lin, Eps, _, _) :- - bb_intern( Is, IsNf), - ( bb_delete( incumbent, _) -> true ; true ), - repair( Lin, LinR), % bb_narrow ... - deref( LinR, Lind), - var_with_def_assign( Dep, Lind), - determine_active_dec( Lind), - bb_loop( Dep, IsNf, Eps), - fail. -bb_inf_internal( _, _, _, Inf, Vertex) :- - bb_delete( incumbent, InfVal-Vertex), % GC - { Inf =:= InfVal }. - -bb_loop( Opt, Is, Eps) :- - bb_reoptimize( Opt, Inf), - bb_better_bound( Inf), - vertex_value( Is, Ivs), - ( bb_first_nonint( Is, Ivs, Eps, Viol, Floor, Ceiling) -> - bb_branch( Viol, Floor, Ceiling), - bb_loop( Opt, Is, Eps) - ; - round_values( Ivs, RoundVertex), - % print( incumbent( Inf-RoundVertex)), nl, - bb_put( incumbent, Inf-RoundVertex) - ). - -% -% added ineqs may have led to binding -% -%vsc: added ! (01/06/06) -bb_reoptimize( Obj, Inf) :- var( Obj), !, iterate_dec( Obj, Inf). -bb_reoptimize( Obj, Inf) :- nonvar( Obj), Inf = Obj. - -bb_better_bound( Inf) :- - bb_get( incumbent, Inc-_), - !, - arith_eval( Inf < Inc). -bb_better_bound( _). - -% :- parallel(bb_branch/3). - -bb_branch( V, U, _) :- { V =< U }. -bb_branch( V, _, L) :- { V >= L }. - -vertex_value( [], []). -vertex_value( [X|Xs], [V|Vs]) :- - rhs_value( X, V), - vertex_value( Xs, Vs). - -%vsc: added ! (01/06/06) -rhs_value( Xn, Value) :- nonvar(Xn), !, Value=Xn. -rhs_value( Xn, Value) :- var(Xn), - deref_var( Xn, Xd), - decompose( Xd, _, R, I), - arith_eval( R+I, Value). - -% -% Need only one as we branch on the first anyway ... -% -bb_first_nonint( [I|Is], [Rhs|Rhss], Eps, Viol, F, C) :- - ( arith_eval( floor(Rhs), Floor), - arith_eval( ceiling(Rhs), Ceiling), - arith_eval(min(Rhs-Floor,Ceiling-Rhs) > Eps) -> - Viol = I, - F = Floor, - C = Ceiling - ; - bb_first_nonint( Is, Rhss, Eps, Viol, F, C) - ). - -round_values( [], []). -round_values( [X|Xs], [Y|Ys]) :- - arith_eval( round(X), Y), - round_values( Xs, Ys). - -bb_intern( [], []). -bb_intern( [X|Xs], [Xi|Xis]) :- - nf( X, Xnf), - bb_intern( Xnf, Xi, X), - bb_intern( Xs, Xis). - -% -% allow more general expressions and conditions? integral(Exp) ??? -% -bb_intern( [], X, _) :- !, arith_eval( 0, X). -bb_intern( [v(I,[])], X, _) :- !, X=I. -bb_intern( [v(One,[X^1])], X, _) :- - arith_eval(One=:=1), - !, - get_atts( X, [type(T),strictness(S)]), - bb_narrow( T, S, X). -bb_intern( _, _, Term) :- - raise_exception( instantiation_error(bb_inf(Term,_,_),1)). - -bb_narrow( t_l(L), S, V) :- - S /\ 2'10 =\= 0, - !, - arith_eval( floor(1+L), B), - { V >= B }. -bb_narrow( t_u(U), S, V) :- - S /\ 2'01 =\= 0, - !, - arith_eval( ceiling(U-1), B), - { V =< B }. -bb_narrow( t_lu(L,U), S, V) :- !, - bb_narrow( t_l(L), S, V), - bb_narrow( t_u(U), S, V). -bb_narrow( _, _, _). - diff --git a/CLPQR/clpqr/bv.pl b/CLPQR/clpqr/bv.pl deleted file mode 100644 index 73769ee47..000000000 --- a/CLPQR/clpqr/bv.pl +++ /dev/null @@ -1,1256 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: bv.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% simplex with bounded variables, ch, 93/12 -% - -% -% TODO: +) var/bound/state classification and maintainance -% +) inc/dec_step: take the best?, at least find unconstrained var first -% +) trivially implied values -% +) avoid eval_rhs through an extra column (Coeff=Rhs) -% +) if an optimum is encountered, record the value as bound !!! -% +) generalized (transparent) attribute handling -% +) coordinate reconsideration cascades -% +) =\= -% +) strict inequalities via =\= -% -) decompose via nonvar test -> no symbolic constants any more ? -% constants complicate the nonlin solver anyway ... -% +) join t_l,l(L), .... into t_l(L), ... -% +) shortcuts for strict ineqs -% -) extra types for vars with l/u bound zero -% -) occurrence lists for indep vars (with coeffs) ??? -% each solve produces one dep var -> push -% only complication: pivots -% -) *incremental* REVISED simplex ?!! -% -% sicstus2.1.9.clp conversion: -% -% -) stable ordering through extra attribute ... -% interpreted vs compiled yields different var order -% -> nasty in R (need different eps) -% -% -) check determinism again -% -% - -:- public {}/1, maximize/1, minimize/1, sup/2, inf/2, imin/2. % xref.pl - -:- use_module( library(ordsets), [ord_add_element/3]). - -% :- use_module( library(deterministic)). - -% -% For the rhs maint. the following events are important: -% -% -) introduction of an indep var at active bound B -% -) narrowing of active bound -% -) swap active bound -% -) pivot -% - -% -% a variables bound (L/U) can have the states: -% -% -) t_none -% -) t_l has a lower bound (not active yet) -% -) t_u -% -) t_L has an active lower bound -% -) t_U -% -) t_lu -% -) t_Lu -% -) t_lU -% - -% ----------------------------------- deref ------------------------------------ % - -:- mode deref( +, -). -% -deref( Lin, Lind) :- - split( Lin, H, I), - normalize_scalar( I, Nonvar), - length( H, Len), - log_deref( Len, H, [], Restd), - add_linear_11( Nonvar, Restd, Lind). - -:- mode log_deref( +, +, -, -). -% -log_deref( 0, Vs, Vs, Lin) :- !, - arith_eval( 0, Z), - Lin = [Z,Z]. -log_deref( 1, [v(K,[X^1])|Vs], Vs, Lin) :- !, - deref_var( X, Lx), - mult_linear_factor( Lx, K, Lin). -log_deref( 2, [v(Kx,[X^1]),v(Ky,[Y^1])|Vs], Vs, Lin) :- !, - deref_var( X, Lx), - deref_var( Y, Ly), - add_linear_ff( Lx, Kx, Ly, Ky, Lin). -log_deref( N, V0, V2, Lin) :- - P is N >> 1, - Q is N - P, - log_deref( P, V0,V1, Lp), - log_deref( Q, V1,V2, Lq), - add_linear_11( Lp, Lq, Lin). - -/* -% -% tail recursive version -% -deref( Lin, Lind) :- - split( Lin, H, I), - normalize_scalar( I, Nonvar), - lin_deref( H, Nonvar, Lind). - -log_deref( _, Lin, [], Res) :- % called from nf.pl - arith_eval( 0, Z), - lin_deref( Lin, [Z,Z], Res). - -lin_deref( [], Ld, Ld). -lin_deref( [v(K,[X^1])|Vs], Li, Lo) :- - deref_var( X, Lx), - add_linear_f1( Lx, K, Li, Lii), - lin_deref( Vs, Lii, Lo). -*/ - -% -% If we see a nonvar here, this is a fault -% -deref_var( X, Lin) :- - get_atts( X, lin(Lin)), !. -deref_var( X, Lin) :- % create a linear var - arith_eval( 0, Z), - arith_eval( 1, One), - Lin = [Z,Z,X*One], - put_atts( X, [order(_),lin(Lin),type(t_none),strictness(2'00)]). - -var_with_def_assign( Var, Lin) :- - decompose( Lin, Hom, _, I), - ( Hom = [], % X=k - Var = I - ; Hom = [V*K|Cs], - ( Cs = [], - arith_eval(K=:=1), - arith_eval(I=:=0) -> % X=Y - Var = V - ; % general case - var_with_def_intern( t_none, Var, Lin, 2'00) - ) - ). - -var_with_def_intern( Type, Var, Lin, Strict) :- - put_atts( Var, [order(_),lin(Lin),type(Type),strictness(Strict)]), - decompose( Lin, Hom, _, _), - get_or_add_class( Var, Class), - same_class( Hom, Class). - -var_intern( Type, Var, Strict) :- - arith_eval( 0, Z), - arith_eval( 1, One), - Lin = [Z,Z,Var*One], - put_atts( Var, [order(_),lin(Lin),type(Type),strictness(Strict)]), - get_or_add_class( Var, _Class). - -% ------------------------------------------------------------------------------ - -% -% [V-Binding]* -% Only place where the linear solver binds variables -% -export_binding( []). -export_binding( [X-Y|Gs]) :- - export_binding( Y, X), - export_binding( Gs). - -% -% numerical stabilizer, clp(r) only -% -export_binding( Y, X) :- var(Y), Y=X. -export_binding( Y, X) :- nonvar(Y), - ( arith_eval( Y=:=0) -> - arith_eval( 0, X) - ; - Y = X - ). - -'solve_='( Nf) :- - deref( Nf, Nfd), - solve( Nfd). - -'solve_=\='( Nf) :- - deref( Nf, Lind), - decompose( Lind, Hom, _, Inhom), - ( Hom = [], arith_eval( Inhom =\= 0) - ; Hom = [_|_], var_with_def_intern( t_none, Nz, Lind, 2'00), - put_atts( Nz, nonzero) - ). - -'solve_<'( Nf) :- - split( Nf, H, I), - ineq( H, I, Nf, strict). - -'solve_=<'( Nf) :- - split( Nf, H, I), - ineq( H, I, Nf, nonstrict). - -maximize( Term) :- - minimize( -Term). - -% -% This is NOT coded as minimize(Expr) :- inf(Expr,Expr). -% -% because the new version of inf/2 only visits -% the vertex where the infimum is assumed and returns -% to the 'current' vertex via backtracking. -% The rationale behind this construction is to eliminate -% all garbage in the solver data structures produced by -% the pivots on the way to the extremal point caused by -% {inf,sup}/{2,4}. -% -% If we are after the infimum/supremum for minimizing/maximizing, -% this strategy may have adverse effects on performance because -% the simplex algorithm is forced to re-discover the -% extremal vertex through the equation {Inf =:= Expr}. -% -% Thus the extra code for {minimize,maximize}/1. -% -% In case someone comes up with an example where -% -% inf(Expr,Expr) -% -% outperforms the provided formulation for minimize - so be it. -% Both forms are available to the user. -% -minimize( Term) :- - wait_linear( Term, Nf, minimize_lin(Nf)). - -minimize_lin( Lin) :- - deref( Lin, Lind), - var_with_def_intern( t_none, Dep, Lind, 2'00), - determine_active_dec( Lind), - iterate_dec( Dep, Inf), - { Dep =:= Inf }. - -sup( Expression, Sup) :- - sup( Expression, Sup, [], []). - -sup( Expression, Sup, Vector, Vertex) :- - inf( -Expression, -Sup, Vector, Vertex). - -inf( Expression, Inf) :- - inf( Expression, Inf, [], []). - -inf( Expression, Inf, Vector, Vertex) :- - wait_linear( Expression, Nf, inf_lin(Nf,Inf,Vector,Vertex)). - -inf_lin( Lin, _, Vector, _) :- - deref( Lin, Lind), - var_with_def_intern( t_none, Dep, Lind, 2'00), - determine_active_dec( Lind), - iterate_dec( Dep, Inf), - vertex_value( Vector, Values), - bb_put( inf, [Inf|Values]), - fail. -inf_lin( _, Infimum, _, Vertex) :- - bb_delete( inf, L), - assign( [Infimum|Vertex], L). - -assign( [], []). -assign( [X|Xs], [Y|Ys]) :- - {X =:= Y}, % more defensive/expressive than X=Y - assign( Xs, Ys). - -% --------------------------------- optimization ------------------------------- % -% -% The _sn(S) =< 0 row might be temporarily infeasible. -% We use reconsider/1 to fix this. -% -% s(S) e [_,0] = d +xi ... -xj, Rhs > 0 so we want to decrease s(S) -% -% positive xi would have to be moved towards their lower bound, -% negative xj would have to be moved towards their upper bound, -% -% the row s(S) does not limit the lower bound of xi -% the row s(S) does not limit the upper bound of xj -% -% a) if some other row R is limiting xk, we pivot(R,xk), -% s(S) will decrease and get more feasible until (b) -% b) if there is no limiting row for some xi: we pivot(s(S),xi) -% xj: we pivot(s(S),xj) -% which cures the infeasibility in one step -% - - -% -% fails if Status = unlimited/2 -% -iterate_dec( OptVar, Opt) :- - get_atts( OptVar, lin(Lin)), - decompose( Lin, H, R, I), - - % arith_eval( R+I, Now), print(min(Now)), nl, - - % dec_step_best( H, Status), - dec_step( H, Status), - ( Status = applied, iterate_dec( OptVar, Opt) - ; Status = optimum, arith_eval( R+I, Opt) - ). - -iterate_inc( OptVar, Opt) :- - get_atts( OptVar, lin(Lin)), - decompose( Lin, H, R, I), - inc_step( H, Status), - ( Status = applied, iterate_inc( OptVar, Opt) - ; Status = optimum, arith_eval( R+I, Opt) - ). - -% -% Status = {optimum,unlimited(Indep,DepT),applied} -% If Status = optimum, the tables have not been changed at all. -% Searches left to right, does not try to find the 'best' pivot -% Therefore we might discover unboundedness only after a few pivots -% -dec_step( [], optimum). -dec_step( [V*K|Vs], Status) :- - get_atts( V, type(W)), - ( W = t_U(U), - ( arith_eval( K > 0) -> - ( lb( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_u(U)) - ; - Status = unlimited(V,t_u(U)) - ) - ; - dec_step( Vs, Status) - ) - ; W = t_lU(L,U), - ( arith_eval( K > 0) -> - Status = applied, - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - dec_step( Vs, Status) - ) - ; W = t_L(L), - ( arith_eval( K < 0) -> - ( ub( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_l(L)) - ; - Status = unlimited(V,t_l(L)) - ) - ; - dec_step( Vs, Status) - ) - ; W = t_Lu(L,U), - ( arith_eval( K < 0) -> - Status = applied, - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - dec_step( Vs, Status) - ) - ; W = t_none, - Status = unlimited(V,t_none) - ). - -inc_step( [], optimum). -inc_step( [V*K|Vs], Status) :- - get_atts( V, type(W)), - ( W = t_U(U), - ( arith_eval( K < 0) -> - ( lb( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_u(U)) - ; - Status = unlimited(V,t_u(U)) - ) - ; - inc_step( Vs, Status) - ) - ; W = t_lU(L,U), - ( arith_eval( K < 0) -> - Status = applied, - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - inc_step( Vs, Status) - ) - ; W = t_L(L), - ( arith_eval( K > 0) -> - ( ub( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_l(L)) - ; - Status = unlimited(V,t_l(L)) - ) - ; - inc_step( Vs, Status) - ) - ; W = t_Lu(L,U), - ( arith_eval( K > 0) -> - Status = applied, - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - inc_step( Vs, Status) - ) - ; W = t_none, - Status = unlimited(V,t_none) - ). - -% ------------------------------ best first heuristic -------------------------- % -% -% A replacement for dec_step/2 that uses a local best first heuristic. -% -% - -dec_step_best( H, Status) :- - dec_eval( H, E), - ( E = unlimited(_,_), - Status = E - ; E = [], - Status = optimum - ; E = [_|_], - Status = applied, - keysort( E, [_-Best|_]), - ( Best = pivot_a(Vub,V,Vb,Wd), pivot_a(Vub,V,Vb,Wd) - ; Best = pivot_b(Vub,V,Vb,Wd), pivot_b(Vub,V,Vb,Wd) - ) - ). - -dec_eval( [], []). -dec_eval( [V*K|Vs], Res) :- - get_atts( V, type(W)), - ( W = t_U(U), - ( arith_eval( K > 0) -> - ( lb( V, Vub-Vb-Limit) -> - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_a(Vub,V,Vb,t_u(U)) | Tail], - dec_eval( Vs, Tail) - ; - Res = unlimited(V,t_u(U)) - ) - ; - dec_eval( Vs, Res) - ) - ; W = t_lU(L,U), - ( arith_eval( K > 0) -> - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-Limit), - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_b(Vub,V,Vb,t_lu(L,U)) | Tail], - dec_eval( Vs, Tail) - ; - dec_eval( Vs, Res) - ) - ; W = t_L(L), - ( arith_eval( K < 0) -> - ( ub( V, Vub-Vb-Limit) -> - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_a(Vub,V,Vb,t_l(L)) | Tail], - dec_eval( Vs, Tail) - ; - Res = unlimited(V,t_l(L)) - ) - ; - dec_eval( Vs, Res) - ) - ; W = t_Lu(L,U), - ( arith_eval( K < 0) -> - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-Limit), - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_b(Vub,V,Vb,t_lu(L,U)) | Tail], - dec_eval( Vs, Tail) - ; - dec_eval( Vs, Res) - ) - ; W = t_none, - Res = unlimited(V,t_none) - ). - -% ------------------------- find the most constraining row --------------------- % -% -% The code for the lower and the upper bound are dual versions of each other. -% The only difference is in the orientation of the comparisons. -% Indeps are ruled out by their types. -% If there is no bound, this fails. -% -% *** The actual lb and ub on an indep variable X are [lu]b + b(X), where b(X) -% is the value of the active bound. -% -% Nota bene: We must NOT consider infeasible rows as candidates to -% leave the basis! -% - -ub( X, Ub) :- - basis( X, Deps), - ub_first( Deps, X, Ub). - -:- mode ub_first( +, ?, -). -% -ub_first( [Dep|Deps], X, Tightest) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - ub_inner( Type, X, Lin, W, Ub), - arith_eval( Ub >= 0) -> - ub( Deps, X, Dep-W-Ub, Tightest) - ; - ub_first( Deps, X, Tightest) - ). - -% -% Invariant: Ub >= 0 and decreasing -% -:- mode ub( +, ?, +, -). -% -ub( [], _, T0,T0). -ub( [Dep|Deps], X, T0,T1) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - ub_inner( Type, X, Lin, W, Ub), - T0 = _-Ubb, - arith_eval( Ub < Ubb), - arith_eval( Ub >= 0) -> % rare failure - ub( Deps, X, Dep-W-Ub,T1) - ; - ub( Deps, X, T0,T1) - ). - -lb( X, Lb) :- - basis( X, Deps), - lb_first( Deps, X, Lb). - -:- mode lb_first( +, ?, -). -% -lb_first( [Dep|Deps], X, Tightest) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - lb_inner( Type, X, Lin, W, Lb), - arith_eval( Lb =< 0) -> - lb( Deps, X, Dep-W-Lb, Tightest) - ; - lb_first( Deps, X, Tightest) - ). - -% -% Invariant: Lb =< 0 and increasing -% -:- mode lb( +, ?, +, -). -% -lb( [], _, T0,T0). -lb( [Dep|Deps], X, T0,T1) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - lb_inner( Type, X, Lin, W, Lb), - T0 = _-Lbb, - arith_eval( Lb > Lbb), - arith_eval( Lb =< 0) -> % rare failure - lb( Deps, X, Dep-W-Lb,T1) - ; - lb( Deps, X, T0,T1) - ). - -% -% Lb =< 0 for feasible rows -% -:- mode lb_inner( +, ?, +, -, -). -% -lb_inner( t_l(L), X, Lin, t_L(L), Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K > 0), - arith_eval( (L-Rhs)/K, Lb). -lb_inner( t_u(U), X, Lin, t_U(U), Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K < 0), - arith_eval( (U-Rhs)/K, Lb). -lb_inner( t_lu(L,U), X, Lin, W, Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - case_signum( K, - ( - W = t_lU(L,U), - arith_eval( (U-Rhs)/K, Lb) - ), - fail, - ( - W = t_Lu(L,U), - arith_eval( (L-Rhs)/K, Lb) - )). - -% -% Ub >= 0 for feasible rows -% -:- mode ub_inner( +, ?, +, -, -). -% -ub_inner( t_l(L), X, Lin, t_L(L), Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K < 0), - arith_eval( (L-Rhs)/K, Ub). -ub_inner( t_u(U), X, Lin, t_U(U), Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K > 0), - arith_eval( (U-Rhs)/K, Ub). -ub_inner( t_lu(L,U), X, Lin, W, Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - case_signum( K, - ( - W = t_Lu(L,U), - arith_eval( (L-Rhs)/K, Ub) - ), - fail, - ( - W = t_lU(L,U), - arith_eval( (U-Rhs)/K, Ub) - )). - -% ---------------------------------- equations --------------------------------- % -% -% backsubstitution will not make the system infeasible, if the bounds on the indep -% vars are obeyed, but some implied values might pop up in rows where X occurs -% -) special case X=Y during bs -> get rid of dependend var(s), alias -% - -solve( Lin) :- - decompose( Lin, H, _, I), - solve( H, Lin, I, Bindings, []), - export_binding( Bindings). - -solve( [], _, I, Bind0,Bind0) :- - arith_eval( I=:=0). % redundant or trivially unsat -solve( H, Lin, _, Bind0,BindT) :- - H = [_|_], % indexing - % - % [] is an empty ord_set, anything will be preferred - % over 9-9 - % - sd( H, [],ClassesUniq, 9-9-0,Category-Selected-_, NV,NVT), - - isolate( Selected, Lin, Lin1), - - ( Category = 1, - put_atts( Selected, lin(Lin1)), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,BindT), - eq_classes( NV, NVT, ClassesUniq) - ; Category = 2, - get_atts( Selected, class(NewC)), - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,BindT) - ; - Bind0 = BindT, - bs( Deps, Selected, Lin1) - ), - eq_classes( NV, NVT, ClassesUniq) - ; Category = 3, - put_atts( Selected, lin(Lin1)), - get_atts( Selected, type(Type)), - deactivate_bound( Type, Selected), - eq_classes( NV, NVT, ClassesUniq), - basis_add( Selected, Basis), - undet_active( Lin1), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,Bind1), - rcbl( Basis, Bind1,BindT) - ; Category = 4, - get_atts( Selected, [type(Type),class(NewC)]), - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,Bind1) - ; - Bind0 = Bind1, - bs( Deps, Selected, Lin1) - ), - deactivate_bound( Type, Selected), - basis_add( Selected, Basis), - % eq_classes( NV, NVT, ClassesUniq), % 4 -> var(NV) - equate( ClassesUniq, _), - undet_active( Lin1), - rcbl( Basis, Bind1,BindT) - ). - -% -% Much like solve, but we solve for a particular variable of type -% t_none -% -solve_x( Lin, X) :- - decompose( Lin, H, _, I), - solve_x( H, Lin, I, X, Bindings, []), - export_binding( Bindings). - -solve_x( [], _, I, _, Bind0,Bind0) :- - arith_eval( I=:=0). % redundant or trivially unsat -solve_x( H, Lin, _, Selected, Bind0,BindT) :- - H = [_|_], % indexing - sd( H, [],ClassesUniq, 9-9-0,_, NV,NVT), - - isolate( Selected, Lin, Lin1), - - ( get_atts( Selected, class(NewC)) -> - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,BindT) - ; - Bind0 = BindT, - bs( Deps, Selected, Lin1) - ), - eq_classes( NV, NVT, ClassesUniq) - ; - put_atts( Selected, lin(Lin1)), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,BindT), - eq_classes( NV, NVT, ClassesUniq) - ). - - - -sd( [], Class0,Class0, Preference0,Preference0, NV0,NV0). -sd( [X*K|Xs], Class0,ClassN, Preference0,PreferenceN, NV0,NVt) :- - ( get_atts( X, class(Xc)) -> % old - NV0 = NV1, - ord_add_element( Class0, Xc, Class1), - ( get_atts( X, type(t_none)) -> - preference( Preference0, 2-X-K, Preference1) - ; - preference( Preference0, 4-X-K, Preference1) - ) - ; % new - Class1 = Class0, - 'C'( NV0, X, NV1), - ( get_atts( X, type(t_none)) -> - preference( Preference0, 1-X-K, Preference1) - ; - preference( Preference0, 3-X-K, Preference1) - ) - ), - sd( Xs, Class1,ClassN, Preference1,PreferenceN, NV1,NVt). - -% -% A is best sofar, B is current -% -preference( A, B, Pref) :- - A = Px-_-_, - B = Py-_-_, - compare( Rel, Px, Py), - ( Rel = =, Pref = B - % ( arith_eval(abs(Ka)= Pref=A ; Pref=B ) - ; Rel = <, Pref = A - ; Rel = >, Pref = B - ). - -% -% equate after attach_class because other classes may contribute -% nonvars and will bind the tail of NV -% -eq_classes( NV, _, Cs) :- var( NV), !, - equate( Cs, _). -eq_classes( NV, NVT, Cs) :- - class_new( Su, NV,NVT, []), - attach_class( NV, Su), - equate( Cs, Su). - -equate( [], _). -equate( [X|Xs], X) :- equate( Xs, X). - -% -% assert: none of the Vars has a class attribute yet -% -attach_class( Xs, _) :- var( Xs), !. -attach_class( [X|Xs], Class) :- - put_atts( X, class(Class)), - attach_class( Xs, Class). - -/** -unconstrained( [X*K|Xs], Uc,Kuc, Rest) :- - ( get_atts( X, type(t_none)) -> - Uc = X, - Kuc = K, - Rest = Xs - ; - Rest = [X*K|Tail], - unconstrained( Xs, Uc,Kuc, Tail) - ). -**/ -/**/ -unconstrained( Lin, Uc,Kuc, Rest) :- - decompose( Lin, H, _, _), - sd( H, [],_, 9-9-0,Category-Uc-_, _,_), - Category =< 2, - delete_factor( Uc, Lin, Rest, Kuc). -/**/ - -% -% point the vars in Lin into the same equivalence class -% maybe join some global data -% -same_class( [], _). -same_class( [X*_|Xs], Class) :- - get_or_add_class( X, Class), - same_class( Xs, Class). - -get_or_add_class( X, Class) :- - get_atts( X, class(ClassX)), - !, - ClassX = Class. % explicit =/2 because of cut -get_or_add_class( X, Class) :- - put_atts( X, class(Class)), - class_new( Class, [X|Tail],Tail, []). % initial class atts - -allvars( X, Allvars) :- - get_atts( X, class(C)), - class_allvars( C, Allvars). - -deactivate_bound( t_l(_), _). -deactivate_bound( t_u(_), _). -deactivate_bound( t_lu(_,_), _). -deactivate_bound( t_L(L), X) :- put_atts( X, type(t_l(L))). -deactivate_bound( t_Lu(L,U), X) :- put_atts( X, type(t_lu(L,U))). -deactivate_bound( t_U(U), X) :- put_atts( X, type(t_u(U))). -deactivate_bound( t_lU(L,U), X) :- put_atts( X, type(t_lu(L,U))). - -intro_at( X, Value, Type) :- - put_atts( X, type(Type)), - ( arith_eval( Value =:= 0) -> - true - ; - backsubst_delta( X, Value) - ). - - -% -% The choice t_lu -> t_Lu is arbitrary -% -undet_active( Lin) :- - decompose( Lin, Lin1, _, _), - undet_active_h( Lin1). - -undet_active_h( []). -undet_active_h( [X*_|Xs]) :- - get_atts( X, type(Type)), - undet_active( Type, X), - undet_active_h( Xs). - -undet_active( t_none, _). % type_activity -undet_active( t_L(_), _). -undet_active( t_Lu(_,_), _). -undet_active( t_U(_), _). -undet_active( t_lU(_,_), _). -undet_active( t_l(L), X) :- intro_at( X, L, t_L(L)). -undet_active( t_u(U), X) :- intro_at( X, U, t_U(U)). -undet_active( t_lu(L,U), X) :- intro_at( X, L, t_Lu(L,U)). - -determine_active_dec( Lin) :- - decompose( Lin, Lin1, _, _), - arith_eval( -1, Mone), - determine_active( Lin1, Mone). - -determine_active_inc( Lin) :- - decompose( Lin, Lin1, _, _), - arith_eval( 1, One), - determine_active( Lin1, One). - -determine_active( [], _). -determine_active( [X*K|Xs], S) :- - get_atts( X, type(Type)), - determine_active( Type, X, K, S), - determine_active( Xs, S). - -determine_active( t_L(_), _, _, _). -determine_active( t_Lu(_,_), _, _, _). -determine_active( t_U(_), _, _, _). -determine_active( t_lU(_,_), _, _, _). -determine_active( t_l(L), X, _, _) :- intro_at( X, L, t_L(L)). -determine_active( t_u(U), X, _, _) :- intro_at( X, U, t_U(U)). -determine_active( t_lu(L,U), X, K, S) :- - case_signum( K*S, - intro_at( X, L, t_Lu(L,U)), - fail, - intro_at( X, U, t_lU(L,U))). - -% -% Careful when an indep turns into t_none !!! -% -detach_bounds( V) :- - get_atts( V, lin(Lin)), - put_atts( V, [type(t_none),strictness(2'00)]), - ( indep( Lin, V) -> - ( ub( V, Vub-Vb-_) -> % exchange against thightest - basis_drop( Vub), - pivot( Vub, V, Vb) - ; lb( V, Vlb-Vb-_) -> - basis_drop( Vlb), - pivot( Vlb, V, Vb) - ; - true - ) - ; - basis_drop( V) - ). - -% ----------------------------- manipulate the basis --------------------------- % - -basis_drop( X) :- - get_atts( X, class(Cv)), - class_basis_drop( Cv, X). - -basis( X, Basis) :- - get_atts( X, class(Cv)), - class_basis( Cv, Basis). - -basis_add( X, NewBasis) :- - get_atts( X, class(Cv)), - class_basis_add( Cv, X, NewBasis). - -basis_pivot( Leave, Enter) :- - get_atts( Leave, class(Cv)), - class_basis_pivot( Cv, Enter, Leave). - -% ----------------------------------- pivot ------------------------------------ % - -% -% Pivot ignoring rhs and active states -% -pivot( Dep, Indep) :- - get_atts( Dep, lin(H)), - delete_factor( Indep, H, H0, Coeff), - arith_eval( -1/Coeff, K), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( H0, K, [Z,Z,Dep*Mone], K, Lin), - backsubst( Indep, Lin). - - -pivot_a( Dep, Indep, Vb,Wd) :- - basis_pivot( Dep, Indep), - pivot( Dep, Indep, Vb), - put_atts( Indep, type(Wd)). - -pivot_b( Vub, V, Vb, Wd) :- - ( Vub == V -> - put_atts( V, type(Vb)), - pivot_b_delta( Vb, Delta), % nonzero(Delta) - backsubst_delta( V, Delta) - ; - pivot_a( Vub, V, Vb,Wd) - ). - -pivot_b_delta( t_Lu(L,U), Delta) :- arith_eval( L-U, Delta). -pivot_b_delta( t_lU(L,U), Delta) :- arith_eval( U-L, Delta). - -select_active_bound( t_L(L), L). -select_active_bound( t_Lu(L,_), L). -select_active_bound( t_U(U), U). -select_active_bound( t_lU(_,U), U). -select_active_bound( t_none, Z) :- arith_eval( 0, Z). -% -% for project.pl -% -select_active_bound( t_l(_), Z) :- arith_eval( 0, Z). -select_active_bound( t_u(_), Z) :- arith_eval( 0, Z). -select_active_bound( t_lu(_,_), Z) :- arith_eval( 0, Z). - - -% -% Pivot taking care of rhs and active states -% -pivot( Dep, Indep, IndAct) :- - get_atts( Dep, lin(H)), - put_atts( Dep, type(IndAct)), - select_active_bound( IndAct, Abv), % Dep or Indep - delete_factor( Indep, H, H0, Coeff), - arith_eval( -1/Coeff, K), - arith_eval( 0, Z), - arith_eval( -1, Mone), - arith_eval( -Abv, Abvm), - add_linear_ff( H0, K, [Z,Abvm,Dep*Mone], K, Lin), - backsubst( Indep, Lin). - -backsubst_delta( X, Delta) :- - arith_eval( 1, One), - arith_eval( 0, Z), - backsubst( X, [Z,Delta,X*One]). - -backsubst( X, Lin) :- - allvars( X, Allvars), - bs( Allvars, X, Lin). -% -% valid if nothing will go ground -% -bs( Xs, _, _) :- var( Xs), !. -bs( [X|Xs], V, Lin) :- - ( get_atts( X, lin(LinX)), - nf_substitute( V, Lin, LinX, LinX1) -> - put_atts( X, lin(LinX1)), - bs( Xs, V, Lin) - ; - bs( Xs, V, Lin) - ). - - -% -% rank increasing backsubstitution -% -bs_collect_bindings( Xs, _, _, Bind0,BindT) :- var( Xs), !, Bind0=BindT. -bs_collect_bindings( [X|Xs], V, Lin, Bind0,BindT) :- - ( get_atts( X, lin(LinX)), - nf_substitute( V, Lin, LinX, LinX1) -> - put_atts( X, lin(LinX1)), - decompose( LinX1, Hom, _, Inhom), - bs_collect_binding( Hom, X, Inhom, Bind0,Bind1), - bs_collect_bindings( Xs, V, Lin, Bind1,BindT) - ; - bs_collect_bindings( Xs, V, Lin, Bind0,BindT) - ). - -% -% The first clause exports bindings, -% the second (no longer) aliasings -% -bs_collect_binding( [], X, Inhom) --> [ X-Inhom ]. -bs_collect_binding( [_|_], _, _) --> []. -/* -bs_collect_binding( [Y*K|Ys], X, Inhom) --> - ( { Ys = [], - Y \== X, - arith_eval( K=:=1), - arith_eval( Inhom=:=0) - } -> - [ X-Y ] - ; - [] - ). -*/ - -% -% reconsider the basis -% -rcbl( [], Bind0,Bind0). -rcbl( [X|Continuation], Bind0,BindT) :- - ( rcb( X, Status, Violated) -> % have a culprit - rcbl_status( Status, X, Continuation, Bind0,BindT, Violated) - ; - rcbl( Continuation, Bind0,BindT) - ). - -% -% reconsider one element of the basis -% later: lift the binds -% -reconsider( X) :- - rcb( X, Status, Violated), - !, - rcbl_status( Status, X, [], Binds,[], Violated), - export_binding( Binds). -reconsider( _). - -% -% Find a basis variable out of its bound or at its bound -% Try to move it into whithin its bound -% a) impossible -> fail -% b) optimum at the bound -> implied value -% c) else look at the remaining basis variables -% -rcb( X, Status, Violated) :- - get_atts( X, [lin(Lin),type(Type)]), - decompose( Lin, H, R, I), - ( Type = t_l(L), - arith_eval( R+I =< L), - Violated = l(L), - inc_step( H, Status) - - ; Type = t_u(U), - arith_eval( R+I >= U), - Violated = u(U), - dec_step( H, Status) - - ; Type = t_lu(L,U), - arith_eval( R+I, At), - ( - arith_eval( At =< L), - Violated = l(L), - inc_step( H, Status) - ; - arith_eval( At >= U), - Violated = u(U), - dec_step( H, Status) - ) - % - % don't care for other types - % - ). - -rcbl_status( optimum, X, Cont, B0,Bt, Violated) :- rcbl_opt( Violated, X, Cont, B0,Bt). -rcbl_status( applied, X, Cont, B0,Bt, Violated) :- rcbl_app( Violated, X, Cont, B0,Bt). -rcbl_status( unlimited(Indep,DepT), X, Cont, B0,Bt, Violated) :- rcbl_unl( Violated, X, Cont, B0,Bt, Indep, DepT). - -% -% Might reach optimum immediately without changing the basis, -% but in general we must assume that there were pivots. -% If the optimum meets the bound, we backsubstitute the implied -% value, solve will call us again to check for further implied -% values or unsatisfiability in the rank increased system. -% -rcbl_opt( l(L), X, Continuation, B0,B1) :- - get_atts( X, [lin(Lin),strictness(Strict),type(Type)]), - decompose( Lin, _, R, I), - arith_eval( R+I, Opt), - case_signum( L-Opt, - ( - narrow_u( Type, X, Opt), % { X =< Opt } - rcbl( Continuation, B0,B1) - ), - ( - Strict /\ 2'10 =:= 0, % meets lower - arith_eval( -Opt, Mop), - normalize_scalar( Mop, MopN), - add_linear_11( MopN, Lin, Lin1), - decompose( Lin1, Hom, _, Inhom), - ( Hom = [], rcbl( Continuation, B0,B1) % would not callback - ; Hom = [_|_], solve( Hom, Lin1, Inhom, B0,B1) - ) - ), - fail - ). -rcbl_opt( u(U), X, Continuation, B0,B1) :- - get_atts( X, [lin(Lin),strictness(Strict),type(Type)]), - decompose( Lin, _, R, I), - arith_eval( R+I, Opt), - case_signum( U-Opt, - fail, - ( - Strict /\ 2'01 =:= 0, % meets upper - arith_eval( -Opt, Mop), - normalize_scalar( Mop, MopN), - add_linear_11( MopN, Lin, Lin1), - decompose( Lin1, Hom, _, Inhom), - ( Hom = [], rcbl( Continuation, B0,B1) % would not callback - ; Hom = [_|_], solve( Hom, Lin1, Inhom, B0,B1) - ) - ), - ( - narrow_l( Type, X, Opt), % { X >= Opt } - rcbl( Continuation, B0,B1) - )). - -% -% Basis has already changed when this is called -% -rcbl_app( l(L), X, Continuation, B0,B1) :- - get_atts( X, lin(Lin)), - decompose( Lin, H, R, I), - ( arith_eval( R+I > L) -> % within bound now - rcbl( Continuation, B0,B1) - ; - % arith_eval( R+I, Val), print( rcbl_app(X:L:Val)), nl, - inc_step( H, Status), - rcbl_status( Status, X, Continuation, B0,B1, l(L)) - ). -rcbl_app( u(U), X, Continuation, B0,B1) :- - get_atts( X, lin(Lin)), - decompose( Lin, H, R, I), - ( arith_eval( R+I < U) -> % within bound now - rcbl( Continuation, B0,B1) - ; - dec_step( H, Status), - rcbl_status( Status, X, Continuation, B0,B1, u(U)) - ). - -% -% This is never called for a t_lu culprit -% -rcbl_unl( l(L), X, Continuation, B0,B1, Indep, DepT) :- - pivot_a( X, Indep, t_L(L), DepT), % changes the basis - rcbl( Continuation, B0,B1). -rcbl_unl( u(U), X, Continuation, B0,B1, Indep, DepT) :- - pivot_a( X, Indep, t_U(U), DepT), % changes the basis - rcbl( Continuation, B0,B1). - -narrow_u( t_u(_), X, U) :- put_atts( X, type(t_u(U))). -narrow_u( t_lu(L,_), X, U) :- put_atts( X, type(t_lu(L,U))). - -narrow_l( t_l(_), X, L) :- put_atts( X, type(t_l(L))). -narrow_l( t_lu(_,U), X, L) :- put_atts( X, type(t_lu(L,U))). - -% ----------------------------------- dump ------------------------------------- - -dump_var( t_none, V, I,H) --> !, - ( { H=[W*K],V==W,arith_eval(I=:=0),arith_eval(K=:=1) } -> % indep var - [] - ; - { nf2sum( H, I, Sum) }, - [ V = Sum ] - ). -dump_var( t_L(L), V, I,H) --> !, dump_var( t_l(L), V, I,H). -dump_var( t_l(L), V, I,H) --> !, - { - H= [_*K|_], % avoid 1 >= 0 - get_atts( V, strictness(Strict)), - Sm is Strict /\ 2'10, - arith_eval( 1/K, Kr), - arith_eval( Kr*(L-I), Li), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum), - ( arith_eval( K > 0) -> - dump_strict( Sm, Sum >= Li, Sum > Li, Result) - ; - dump_strict( Sm, Sum =< Li, Sum < Li, Result) - ) - }, - [ Result ]. -dump_var( t_U(U), V, I,H) --> !, dump_var( t_u(U), V, I,H). -dump_var( t_u(U), V, I,H) --> !, - { - H= [_*K|_], % avoid 0 =< 1 - get_atts( V, strictness(Strict)), - Sm is Strict /\ 2'01, - arith_eval( 1/K, Kr), - arith_eval( Kr*(U-I), Ui), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum), - ( arith_eval( K > 0) -> - dump_strict( Sm, Sum =< Ui, Sum < Ui, Result) - ; - dump_strict( Sm, Sum >= Ui, Sum > Ui, Result) - ) - }, - [ Result ]. -dump_var( t_Lu(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( t_lU(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( t_lu(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( T, V, I,H) --> - [ V:T:I+H ]. - -dump_strict( 0, Result, _, Result). -dump_strict( 1, _, Result, Result). -dump_strict( 2, _, Result, Result). - -dump_nz( _, H, I) --> - { - H = [_*K|_], - arith_eval( 1/K, Kr), - arith_eval( -Kr*I, I1), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum) - }, - [ Sum =\= I1 ]. diff --git a/CLPQR/clpqr/bv.yap b/CLPQR/clpqr/bv.yap deleted file mode 100644 index d1f62e1fc..000000000 --- a/CLPQR/clpqr/bv.yap +++ /dev/null @@ -1,1266 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: bv.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% simplex with bounded variables, ch, 93/12 -% - -% -% TODO: +) var/bound/state classification and maintainance -% +) inc/dec_step: take the best?, at least find unconstrained var first -% +) trivially implied values -% +) avoid eval_rhs through an extra column (Coeff=Rhs) -% +) if an optimum is encountered, record the value as bound !!! -% +) generalized (transparent) attribute handling -% +) coordinate reconsideration cascades -% +) =\= -% +) strict inequalities via =\= -% -) decompose via nonvar test -> no symbolic constants any more ? -% constants complicate the nonlin solver anyway ... -% +) join t_l,l(L), .... into t_l(L), ... -% +) shortcuts for strict ineqs -% -) extra types for vars with l/u bound zero -% -) occurrence lists for indep vars (with coeffs) ??? -% each solve produces one dep var -> push -% only complication: pivots -% -) *incremental* REVISED simplex ?!! -% -% sicstus2.1.9.clp conversion: -% -% -) stable ordering through extra attribute ... -% interpreted vs compiled yields different var order -% -> nasty in R (need different eps) -% -% -) check determinism again -% -% - -:- public {}/1, maximize/1, minimize/1, sup/2, inf/2, imin/2. % xref.pl - -:- use_module( library(ordsets), [ord_add_element/3]). - -% :- use_module( library(deterministic)). - -% -% For the rhs maint. the following events are important: -% -% -) introduction of an indep var at active bound B -% -) narrowing of active bound -% -) swap active bound -% -) pivot -% - -% -% a variables bound (L/U) can have the states: -% -% -) t_none -% -) t_l has a lower bound (not active yet) -% -) t_u -% -) t_L has an active lower bound -% -) t_U -% -) t_lu -% -) t_Lu -% -) t_lU -% - -% ----------------------------------- deref ------------------------------------ % - -%:- mode deref( +, -). -% -deref( Lin, Lind) :- - split( Lin, H, I), - normalize_scalar( I, Nonvar), - length( H, Len), - log_deref( Len, H, [], Restd), - add_linear_11( Nonvar, Restd, Lind). - -%:- mode log_deref( +, +, -, -). -% -log_deref( 0, Vs, Vs, Lin) :- !, - arith_eval( 0, Z), - Lin = [Z,Z]. -log_deref( 1, [v(K,[X^1])|Vs], Vs, Lin) :- !, - deref_var( X, Lx), - mult_linear_factor( Lx, K, Lin). -log_deref( 2, [v(Kx,[X^1]),v(Ky,[Y^1])|Vs], Vs, Lin) :- !, - deref_var( X, Lx), - deref_var( Y, Ly), - add_linear_ff( Lx, Kx, Ly, Ky, Lin). -log_deref( N, V0, V2, Lin) :- - P is N >> 1, - Q is N - P, - log_deref( P, V0,V1, Lp), - log_deref( Q, V1,V2, Lq), - add_linear_11( Lp, Lq, Lin). - -/* -% -% tail recursive version -% -deref( Lin, Lind) :- - split( Lin, H, I), - normalize_scalar( I, Nonvar), - lin_deref( H, Nonvar, Lind). - -log_deref( _, Lin, [], Res) :- % called from nf.pl - arith_eval( 0, Z), - lin_deref( Lin, [Z,Z], Res). - -lin_deref( [], Ld, Ld). -lin_deref( [v(K,[X^1])|Vs], Li, Lo) :- - deref_var( X, Lx), - add_linear_f1( Lx, K, Li, Lii), - lin_deref( Vs, Lii, Lo). -*/ - -% -% If we see a nonvar here, this is a fault -% - -deref_var( X, Lin) :- - get_atts( X, lin(Lin)), !. - -deref_var( X, Lin) :- % create a linear var - arith_eval( 0, Z), - arith_eval( 1, One), - Lin = [Z,Z,X*One], - put_atts( X, [order(_),lin(Lin),type(t_none),strictness(2'00)]). - -var_with_def_assign( Var, Lin) :- - decompose( Lin, Hom, _, I), - ( Hom = [], % X=k - Var = I - ; Hom = [V*K|Cs], - ( Cs = [], - arith_eval(K=:=1), - arith_eval(I=:=0) -> % X=Y - Var = V - ; % general case - var_with_def_intern( t_none, Var, Lin, 2'00) - ) - ). - -var_with_def_intern( Type, Var, Lin, Strict) :- - put_atts( Var, [order(_),lin(Lin),type(Type),strictness(Strict)]), - decompose( Lin, Hom, _, _), - get_or_add_class( Var, Class), - same_class( Hom, Class). - -var_intern( Type, Var, Strict) :- - arith_eval( 0, Z), - arith_eval( 1, One), - Lin = [Z,Z,Var*One], - put_atts( Var, [order(_),lin(Lin),type(Type),strictness(Strict)]), - get_or_add_class( Var, _Class). - -% ------------------------------------------------------------------------------ - -% -% [V-Binding]* -% Only place where the linear solver binds variables -% -export_binding( []). -export_binding( [X-Y|Gs]) :- - export_binding( Y, X), - export_binding( Gs). - -% -% numerical stabilizer, clp(r) only -% -export_binding( Y, X) :- var(Y), !, Y=X. %vsc: added cut here (01/06/06) -export_binding( Y, X) :- nonvar(Y), - ( arith_eval( Y=:=0) -> - arith_eval( 0, X) - ; - Y = X - ). - -'solve_='( Nf) :- - deref( Nf, Nfd), - solve( Nfd). - -'solve_=\\='( Nf) :- % vsc - deref( Nf, Lind), - decompose( Lind, Hom, _, Inhom), - ( Hom = [], arith_eval( Inhom =\= 0) - ; Hom = [_|_], var_with_def_intern( t_none, Nz, Lind, 2'00), - put_atts( Nz, nonzero) - ). - -'solve_<'( Nf) :- - split( Nf, H, I), - ineq( H, I, Nf, strict). - -'solve_=<'( Nf) :- - split( Nf, H, I), - ineq( H, I, Nf, nonstrict). - -maximize( Term) :- - minimize( -Term). - -% -% This is NOT coded as minimize(Expr) :- inf(Expr,Expr). -% -% because the new version of inf/2 only visits -% the vertex where the infimum is assumed and returns -% to the 'current' vertex via backtracking. -% The rationale behind this construction is to eliminate -% all garbage in the solver data structures produced by -% the pivots on the way to the extremal point caused by -% {inf,sup}/{2,4}. -% -% If we are after the infimum/supremum for minimizing/maximizing, -% this strategy may have adverse effects on performance because -% the simplex algorithm is forced to re-discover the -% extremal vertex through the equation {Inf =:= Expr}. -% -% Thus the extra code for {minimize,maximize}/1. -% -% In case someone comes up with an example where -% -% inf(Expr,Expr) -% -% outperforms the provided formulation for minimize - so be it. -% Both forms are available to the user. -% -minimize( Term) :- - wait_linear( Term, Nf, minimize_lin(Nf)). - -minimize_lin( Lin) :- - deref( Lin, Lind), - var_with_def_intern( t_none, Dep, Lind, 2'00), - determine_active_dec( Lind), - iterate_dec( Dep, Inf), - { Dep =:= Inf }. - -sup( Expression, Sup) :- - sup( Expression, Sup, [], []). - -sup( Expression, Sup, Vector, Vertex) :- - inf( -Expression, -Sup, Vector, Vertex). - -inf( Expression, Inf) :- - inf( Expression, Inf, [], []). - -inf( Expression, Inf, Vector, Vertex) :- - wait_linear( Expression, Nf, inf_lin(Nf,Inf,Vector,Vertex)). - -inf_lin( Lin, _, Vector, _) :- - deref( Lin, Lind), - var_with_def_intern( t_none, Dep, Lind, 2'00), - determine_active_dec( Lind), - iterate_dec( Dep, Inf), - vertex_value( Vector, Values), - bb_put( inf, [Inf|Values]), - fail. -inf_lin( _, Infimum, _, Vertex) :- - bb_delete( inf, L), - assign( [Infimum|Vertex], L). - -assign( [], []). -assign( [X|Xs], [Y|Ys]) :- - {X =:= Y}, % more defensive/expressive than X=Y - assign( Xs, Ys). - -% --------------------------------- optimization ------------------------------- % -% -% The _sn(S) =< 0 row might be temporarily infeasible. -% We use reconsider/1 to fix this. -% -% s(S) e [_,0] = d +xi ... -xj, Rhs > 0 so we want to decrease s(S) -% -% positive xi would have to be moved towards their lower bound, -% negative xj would have to be moved towards their upper bound, -% -% the row s(S) does not limit the lower bound of xi -% the row s(S) does not limit the upper bound of xj -% -% a) if some other row R is limiting xk, we pivot(R,xk), -% s(S) will decrease and get more feasible until (b) -% b) if there is no limiting row for some xi: we pivot(s(S),xi) -% xj: we pivot(s(S),xj) -% which cures the infeasibility in one step -% - - -% -% fails if Status = unlimited/2 -% -iterate_dec( OptVar, Opt) :- - get_atts( OptVar, lin(Lin)), - decompose( Lin, H, R, I), - - % arith_eval( R+I, Now), print(min(Now)), nl, - - % dec_step_best( H, Status), - %vsc: added -> (01/06/06) - dec_step( H, Status), - ( Status = applied -> iterate_dec( OptVar, Opt) - ; Status = optimum -> arith_eval( R+I, Opt) - ). - -iterate_inc( OptVar, Opt) :- - get_atts( OptVar, lin(Lin)), - decompose( Lin, H, R, I), - inc_step( H, Status), - %vsc: added -> (01/06/06) - ( Status = applied -> iterate_inc( OptVar, Opt) - ; Status = optimum -> arith_eval( R+I, Opt) - ). - -% -% Status = {optimum,unlimited(Indep,DepT),applied} -% If Status = optimum, the tables have not been changed at all. -% Searches left to right, does not try to find the 'best' pivot -% Therefore we might discover unboundedness only after a few pivots -% -dec_step( [], optimum). -dec_step( [V*K|Vs], Status) :- - get_atts( V, type(W)), - %vsc: added -> (01/06/06) - ( W = t_U(U) -> - ( arith_eval( K > 0) -> - ( lb( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_u(U)) - ; - Status = unlimited(V,t_u(U)) - ) - ; - dec_step( Vs, Status) - ) - ; W = t_lU(L,U) -> - ( arith_eval( K > 0) -> - Status = applied, - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - dec_step( Vs, Status) - ) - ; W = t_L(L) -> - ( arith_eval( K < 0) -> - ( ub( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_l(L)) - ; - Status = unlimited(V,t_l(L)) - ) - ; - dec_step( Vs, Status) - ) - ; W = t_Lu(L,U) -> - ( arith_eval( K < 0) -> - Status = applied, - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - dec_step( Vs, Status) - ) - ; W = t_none -> - Status = unlimited(V,t_none) - ). - -inc_step( [], optimum). -inc_step( [V*K|Vs], Status) :- - get_atts( V, type(W)), - %vsc: added -> (01/06/06) - ( W = t_U(U) -> - ( arith_eval( K < 0) -> - ( lb( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_u(U)) - ; - Status = unlimited(V,t_u(U)) - ) - ; - inc_step( Vs, Status) - ) - ; W = t_lU(L,U) -> - ( arith_eval( K < 0) -> - Status = applied, - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - inc_step( Vs, Status) - ) - ; W = t_L(L) -> - ( arith_eval( K > 0) -> - ( ub( V, Vub-Vb-_) -> - Status = applied, - pivot_a(Vub,V,Vb,t_l(L)) - ; - Status = unlimited(V,t_l(L)) - ) - ; - inc_step( Vs, Status) - ) - ; W = t_Lu(L,U) -> - ( arith_eval( K > 0) -> - Status = applied, - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-_), - pivot_b(Vub,V,Vb,t_lu(L,U)) - ; - inc_step( Vs, Status) - ) - ; W = t_none -> - Status = unlimited(V,t_none) - ). - -% ------------------------------ best first heuristic -------------------------- % -% -% A replacement for dec_step/2 that uses a local best first heuristic. -% -% - -dec_step_best( H, Status) :- - dec_eval( H, E), - ( E = unlimited(_,_), - Status = E - ; E = [], - Status = optimum - ; E = [_|_], - Status = applied, - keysort( E, [_-Best|_]), - ( Best = pivot_a(Vub,V,Vb,Wd), pivot_a(Vub,V,Vb,Wd) - ; Best = pivot_b(Vub,V,Vb,Wd), pivot_b(Vub,V,Vb,Wd) - ) - ). - -dec_eval( [], []). -dec_eval( [V*K|Vs], Res) :- - get_atts( V, type(W)), - ( W = t_U(U), - ( arith_eval( K > 0) -> - ( lb( V, Vub-Vb-Limit) -> - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_a(Vub,V,Vb,t_u(U)) | Tail], - dec_eval( Vs, Tail) - ; - Res = unlimited(V,t_u(U)) - ) - ; - dec_eval( Vs, Res) - ) - ; W = t_lU(L,U), - ( arith_eval( K > 0) -> - arith_eval( L-U, Init), - basis( V, Deps), - lb( Deps, V, V-t_Lu(L,U)-Init, Vub-Vb-Limit), - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_b(Vub,V,Vb,t_lu(L,U)) | Tail], - dec_eval( Vs, Tail) - ; - dec_eval( Vs, Res) - ) - ; W = t_L(L), - ( arith_eval( K < 0) -> - ( ub( V, Vub-Vb-Limit) -> - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_a(Vub,V,Vb,t_l(L)) | Tail], - dec_eval( Vs, Tail) - ; - Res = unlimited(V,t_l(L)) - ) - ; - dec_eval( Vs, Res) - ) - ; W = t_Lu(L,U), - ( arith_eval( K < 0) -> - arith_eval( U-L, Init), - basis( V, Deps), - ub( Deps, V, V-t_lU(L,U)-Init, Vub-Vb-Limit), - arith_eval( float(Limit*K), Delta), - Res = [Delta-pivot_b(Vub,V,Vb,t_lu(L,U)) | Tail], - dec_eval( Vs, Tail) - ; - dec_eval( Vs, Res) - ) - ; W = t_none, - Res = unlimited(V,t_none) - ). - -% ------------------------- find the most constraining row --------------------- % -% -% The code for the lower and the upper bound are dual versions of each other. -% The only difference is in the orientation of the comparisons. -% Indeps are ruled out by their types. -% If there is no bound, this fails. -% -% *** The actual lb and ub on an indep variable X are [lu]b + b(X), where b(X) -% is the value of the active bound. -% -% Nota bene: We must NOT consider infeasible rows as candidates to -% leave the basis! -% - -ub( X, Ub) :- - basis( X, Deps), - ub_first( Deps, X, Ub). - -%:- mode ub_first( +, ?, -). -% -ub_first( [Dep|Deps], X, Tightest) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - ub_inner( Type, X, Lin, W, Ub), - arith_eval( Ub >= 0) -> - ub( Deps, X, Dep-W-Ub, Tightest) - ; - ub_first( Deps, X, Tightest) - ). - -% -% Invariant: Ub >= 0 and decreasing -% -%:- mode ub( +, ?, +, -). -% -ub( [], _, T0,T0). -ub( [Dep|Deps], X, T0,T1) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - ub_inner( Type, X, Lin, W, Ub), - T0 = _-Ubb, - arith_eval( Ub < Ubb), - arith_eval( Ub >= 0) -> % rare failure - ub( Deps, X, Dep-W-Ub,T1) - ; - ub( Deps, X, T0,T1) - ). - -lb( X, Lb) :- - basis( X, Deps), - lb_first( Deps, X, Lb). - -%:- mode lb_first( +, ?, -). -% -lb_first( [Dep|Deps], X, Tightest) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - lb_inner( Type, X, Lin, W, Lb), - arith_eval( Lb =< 0) -> - lb( Deps, X, Dep-W-Lb, Tightest) - ; - lb_first( Deps, X, Tightest) - ). - -% -% Invariant: Lb =< 0 and increasing -% -%:- mode lb( +, ?, +, -). -% -lb( [], _, T0,T0). -lb( [Dep|Deps], X, T0,T1) :- - ( get_atts( Dep, [lin(Lin),type(Type)]), - lb_inner( Type, X, Lin, W, Lb), - T0 = _-Lbb, - arith_eval( Lb > Lbb), - arith_eval( Lb =< 0) -> % rare failure - lb( Deps, X, Dep-W-Lb,T1) - ; - lb( Deps, X, T0,T1) - ). - -% -% Lb =< 0 for feasible rows -% -%:- mode lb_inner( +, ?, +, -, -). -% -lb_inner( t_l(L), X, Lin, t_L(L), Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K > 0), - arith_eval( (L-Rhs)/K, Lb). -lb_inner( t_u(U), X, Lin, t_U(U), Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K < 0), - arith_eval( (U-Rhs)/K, Lb). -lb_inner( t_lu(L,U), X, Lin, W, Lb) :- - nf_rhs_x( Lin, X, Rhs, K), - case_signum( K, - ( - W = t_lU(L,U), - arith_eval( (U-Rhs)/K, Lb) - ), - fail, - ( - W = t_Lu(L,U), - arith_eval( (L-Rhs)/K, Lb) - )). - -% -% Ub >= 0 for feasible rows -% -%:- mode ub_inner( +, ?, +, -, -). -% -ub_inner( t_l(L), X, Lin, t_L(L), Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K < 0), - arith_eval( (L-Rhs)/K, Ub). -ub_inner( t_u(U), X, Lin, t_U(U), Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - arith_eval( K > 0), - arith_eval( (U-Rhs)/K, Ub). -ub_inner( t_lu(L,U), X, Lin, W, Ub) :- - nf_rhs_x( Lin, X, Rhs, K), - case_signum( K, - ( - W = t_Lu(L,U), - arith_eval( (L-Rhs)/K, Ub) - ), - fail, - ( - W = t_lU(L,U), - arith_eval( (U-Rhs)/K, Ub) - )). - -% ---------------------------------- equations --------------------------------- % -% -% backsubstitution will not make the system infeasible, if the bounds on the indep -% vars are obeyed, but some implied values might pop up in rows where X occurs -% -) special case X=Y during bs -> get rid of dependend var(s), alias -% - -solve( Lin) :- - decompose( Lin, H, _, I), - solve( H, Lin, I, Bindings, []), - export_binding( Bindings). - -solve( [], _, I, Bind0,Bind0) :- - arith_eval( I=:=0). % redundant or trivially unsat -%vsc: changed to list in head (01/06/06) -solve( [HHd|HTl], Lin, _, Bind0,BindT) :- - % - % [] is an empty ord_set, anything will be preferred - % over 9-9 - % - sd( [HHd|HTl], [],ClassesUniq, 9-9-0,Category-Selected-_, NV,NVT), - - isolate( Selected, Lin, Lin1), - - %vsc: added -> (01/06/06) - ( Category = 1 -> - put_atts( Selected, lin(Lin1)), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,BindT), - eq_classes( NV, NVT, ClassesUniq) - ; Category = 2 -> - get_atts( Selected, class(NewC)), - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,BindT) - ; - Bind0 = BindT, - bs( Deps, Selected, Lin1) - ), - eq_classes( NV, NVT, ClassesUniq) - ; Category = 3 -> - put_atts( Selected, lin(Lin1)), - get_atts( Selected, type(Type)), - deactivate_bound( Type, Selected), - eq_classes( NV, NVT, ClassesUniq), - basis_add( Selected, Basis), - undet_active( Lin1), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,Bind1), - rcbl( Basis, Bind1,BindT) - ; Category = 4 -> - get_atts( Selected, [type(Type),class(NewC)]), - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,Bind1) - ; - Bind0 = Bind1, - bs( Deps, Selected, Lin1) - ), - deactivate_bound( Type, Selected), - basis_add( Selected, Basis), - % eq_classes( NV, NVT, ClassesUniq), % 4 -> var(NV) - equate( ClassesUniq, _), - undet_active( Lin1), - rcbl( Basis, Bind1,BindT) - ). - -% -% Much like solve, but we solve for a particular variable of type -% t_none -% -solve_x( Lin, X) :- - decompose( Lin, H, _, I), - solve_x( H, Lin, I, X, Bindings, []), - export_binding( Bindings). - -solve_x( [], _, I, _, Bind0,Bind0) :- - arith_eval( I=:=0). % redundant or trivially unsat -solve_x( H, Lin, _, Selected, Bind0,BindT) :- - H = [_|_], % indexing - sd( H, [],ClassesUniq, 9-9-0,_, NV,NVT), - - isolate( Selected, Lin, Lin1), - - ( get_atts( Selected, class(NewC)) -> - class_allvars( NewC, Deps), - ( ClassesUniq = [_] -> % rank increasing - bs_collect_bindings( Deps, Selected, Lin1, Bind0,BindT) - ; - Bind0 = BindT, - bs( Deps, Selected, Lin1) - ), - eq_classes( NV, NVT, ClassesUniq) - ; - put_atts( Selected, lin(Lin1)), - decompose( Lin1, Hom, _, Inhom), - bs_collect_binding( Hom, Selected, Inhom, Bind0,BindT), - eq_classes( NV, NVT, ClassesUniq) - ). - - - -sd( [], Class0,Class0, Preference0,Preference0, NV0,NV0). -sd( [X*K|Xs], Class0,ClassN, Preference0,PreferenceN, NV0,NVt) :- - ( get_atts( X, class(Xc)) -> % old - NV0 = NV1, - ord_add_element( Class0, Xc, Class1), - ( get_atts( X, type(t_none)) -> - preference( Preference0, 2-X-K, Preference1) - ; - preference( Preference0, 4-X-K, Preference1) - ) - ; % new - Class1 = Class0, - 'C'( NV0, X, NV1), - ( get_atts( X, type(t_none)) -> - preference( Preference0, 1-X-K, Preference1) - ; - preference( Preference0, 3-X-K, Preference1) - ) - ), - sd( Xs, Class1,ClassN, Preference1,PreferenceN, NV1,NVt). - -% -% A is best sofar, B is current -% -preference( A, B, Pref) :- - A = Px-_-_, - B = Py-_-_, - compare( Rel, Px, Py), - %vsc: added -> (01/06/06) - ( Rel = = -> Pref = B - % ( arith_eval(abs(Ka)= Pref=A ; Pref=B ) - ; Rel = < -> Pref = A - ; Rel = > -> Pref = B - ). - -% -% equate after attach_class because other classes may contribute -% nonvars and will bind the tail of NV -% -eq_classes( NV, _, Cs) :- var( NV), !, - equate( Cs, _). -eq_classes( NV, NVT, Cs) :- - class_new( Su, NV,NVT, []), - attach_class( NV, Su), - equate( Cs, Su). - -equate( [], _). -equate( [X|Xs], X) :- equate( Xs, X). - -% -% assert: none of the Vars has a class attribute yet -% -attach_class( Xs, _) :- var( Xs), !. -attach_class( [X|Xs], Class) :- - put_atts( X, class(Class)), - attach_class( Xs, Class). - -/** -unconstrained( [X*K|Xs], Uc,Kuc, Rest) :- - ( get_atts( X, type(t_none)) -> - Uc = X, - Kuc = K, - Rest = Xs - ; - Rest = [X*K|Tail], - unconstrained( Xs, Uc,Kuc, Tail) - ). -**/ -/**/ -unconstrained( Lin, Uc,Kuc, Rest) :- - decompose( Lin, H, _, _), - sd( H, [],_, 9-9-0,Category-Uc-_, _,_), - Category =< 2, - delete_factor( Uc, Lin, Rest, Kuc). -/**/ - -% -% point the vars in Lin into the same equivalence class -% maybe join some global data -% -same_class( [], _). -same_class( [X*_|Xs], Class) :- - get_or_add_class( X, Class), - same_class( Xs, Class). - -get_or_add_class( X, Class) :- - get_atts( X, class(ClassX)), - !, - ClassX = Class. % explicit =/2 because of cut -get_or_add_class( X, Class) :- - put_atts( X, class(Class)), - class_new( Class, [X|Tail],Tail, []). % initial class atts - -allvars( X, Allvars) :- - get_atts( X, class(C)), - class_allvars( C, Allvars). - -deactivate_bound( t_l(_), _). -deactivate_bound( t_u(_), _). -deactivate_bound( t_lu(_,_), _). -deactivate_bound( t_L(L), X) :- put_atts( X, type(t_l(L))). -deactivate_bound( t_Lu(L,U), X) :- put_atts( X, type(t_lu(L,U))). -deactivate_bound( t_U(U), X) :- put_atts( X, type(t_u(U))). -deactivate_bound( t_lU(L,U), X) :- put_atts( X, type(t_lu(L,U))). - -intro_at( X, Value, Type) :- - put_atts( X, type(Type)), - ( arith_eval( Value =:= 0) -> - true - ; - backsubst_delta( X, Value) - ). - - -% -% The choice t_lu -> t_Lu is arbitrary -% -undet_active( Lin) :- - decompose( Lin, Lin1, _, _), - undet_active_h( Lin1). - -undet_active_h( []). -undet_active_h( [X*_|Xs]) :- - get_atts( X, type(Type)), - undet_active( Type, X), - undet_active_h( Xs). - -undet_active( t_none, _). % type_activity -undet_active( t_L(_), _). -undet_active( t_Lu(_,_), _). -undet_active( t_U(_), _). -undet_active( t_lU(_,_), _). -undet_active( t_l(L), X) :- intro_at( X, L, t_L(L)). -undet_active( t_u(U), X) :- intro_at( X, U, t_U(U)). -undet_active( t_lu(L,U), X) :- intro_at( X, L, t_Lu(L,U)). - -determine_active_dec( Lin) :- - decompose( Lin, Lin1, _, _), - arith_eval( -1, Mone), - determine_active( Lin1, Mone). - -determine_active_inc( Lin) :- - decompose( Lin, Lin1, _, _), - arith_eval( 1, One), - determine_active( Lin1, One). - -determine_active( [], _). -determine_active( [X*K|Xs], S) :- - get_atts( X, type(Type)), - determine_active( Type, X, K, S), - determine_active( Xs, S). - -determine_active( t_L(_), _, _, _). -determine_active( t_Lu(_,_), _, _, _). -determine_active( t_U(_), _, _, _). -determine_active( t_lU(_,_), _, _, _). -determine_active( t_l(L), X, _, _) :- intro_at( X, L, t_L(L)). -determine_active( t_u(U), X, _, _) :- intro_at( X, U, t_U(U)). -determine_active( t_lu(L,U), X, K, S) :- - case_signum( K*S, - intro_at( X, L, t_Lu(L,U)), - fail, - intro_at( X, U, t_lU(L,U))). - -% -% Careful when an indep turns into t_none !!! -% -detach_bounds( V) :- - get_atts( V, lin(Lin)), - put_atts( V, [type(t_none),strictness(2'00)]), - ( indep( Lin, V) -> - ( ub( V, Vub-Vb-_) -> % exchange against thightest - basis_drop( Vub), - pivot( Vub, V, Vb) - ; lb( V, Vlb-Vb-_) -> - basis_drop( Vlb), - pivot( Vlb, V, Vb) - ; - true - ) - ; - basis_drop( V) - ). - -% ----------------------------- manipulate the basis --------------------------- % - -basis_drop( X) :- - get_atts( X, class(Cv)), - class_basis_drop( Cv, X). - -basis( X, Basis) :- - get_atts( X, class(Cv)), - class_basis( Cv, Basis). - -basis_add( X, NewBasis) :- - get_atts( X, class(Cv)), - class_basis_add( Cv, X, NewBasis). - -basis_pivot( Leave, Enter) :- - get_atts( Leave, class(Cv)), - class_basis_pivot( Cv, Enter, Leave). - -% ----------------------------------- pivot ------------------------------------ % - -% -% Pivot ignoring rhs and active states -% -pivot( Dep, Indep) :- - get_atts( Dep, lin(H)), - delete_factor( Indep, H, H0, Coeff), - arith_eval( -1/Coeff, K), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( H0, K, [Z,Z,Dep*Mone], K, Lin), - backsubst( Indep, Lin). - - -pivot_a( Dep, Indep, Vb,Wd) :- - basis_pivot( Dep, Indep), - pivot( Dep, Indep, Vb), - put_atts( Indep, type(Wd)). - -pivot_b( Vub, V, Vb, Wd) :- - ( Vub == V -> - put_atts( V, type(Vb)), - pivot_b_delta( Vb, Delta), % nonzero(Delta) - backsubst_delta( V, Delta) - ; - pivot_a( Vub, V, Vb,Wd) - ). - -pivot_b_delta( t_Lu(L,U), Delta) :- arith_eval( L-U, Delta). -pivot_b_delta( t_lU(L,U), Delta) :- arith_eval( U-L, Delta). - -select_active_bound( t_L(L), L). -select_active_bound( t_Lu(L,_), L). -select_active_bound( t_U(U), U). -select_active_bound( t_lU(_,U), U). -select_active_bound( t_none, Z) :- arith_eval( 0, Z). -% -% for project.pl -% -select_active_bound( t_l(_), Z) :- arith_eval( 0, Z). -select_active_bound( t_u(_), Z) :- arith_eval( 0, Z). -select_active_bound( t_lu(_,_), Z) :- arith_eval( 0, Z). - - -% -% Pivot taking care of rhs and active states -% -pivot( Dep, Indep, IndAct) :- - get_atts( Dep, lin(H)), - put_atts( Dep, type(IndAct)), - select_active_bound( IndAct, Abv), % Dep or Indep - delete_factor( Indep, H, H0, Coeff), - arith_eval( -1/Coeff, K), - arith_eval( 0, Z), - arith_eval( -1, Mone), - arith_eval( -Abv, Abvm), - add_linear_ff( H0, K, [Z,Abvm,Dep*Mone], K, Lin), - backsubst( Indep, Lin). - -backsubst_delta( X, Delta) :- - arith_eval( 1, One), - arith_eval( 0, Z), - backsubst( X, [Z,Delta,X*One]). - -backsubst( X, Lin) :- - allvars( X, Allvars), - bs( Allvars, X, Lin). -% -% valid if nothing will go ground -% -bs( Xs, _, _) :- var( Xs), !. -bs( [X|Xs], V, Lin) :- - ( get_atts( X, lin(LinX)), - nf_substitute( V, Lin, LinX, LinX1) -> - put_atts( X, lin(LinX1)), - bs( Xs, V, Lin) - ; - bs( Xs, V, Lin) - ). - - -% -% rank increasing backsubstitution -% -bs_collect_bindings( Xs, _, _, Bind0,BindT) :- var( Xs), !, Bind0=BindT. -bs_collect_bindings( [X|Xs], V, Lin, Bind0,BindT) :- - ( get_atts( X, lin(LinX)), - nf_substitute( V, Lin, LinX, LinX1) -> - put_atts( X, lin(LinX1)), - decompose( LinX1, Hom, _, Inhom), - bs_collect_binding( Hom, X, Inhom, Bind0,Bind1), - bs_collect_bindings( Xs, V, Lin, Bind1,BindT) - ; - bs_collect_bindings( Xs, V, Lin, Bind0,BindT) - ). - -% -% The first clause exports bindings, -% the second (no longer) aliasings -% -bs_collect_binding( [], X, Inhom) --> [ X-Inhom ]. -bs_collect_binding( [_|_], _, _) --> []. -/* -bs_collect_binding( [Y*K|Ys], X, Inhom) --> - ( { Ys = [], - Y \== X, - arith_eval( K=:=1), - arith_eval( Inhom=:=0) - } -> - [ X-Y ] - ; - [] - ). -*/ - -% -% reconsider the basis -% -rcbl( [], Bind0,Bind0). -rcbl( [X|Continuation], Bind0,BindT) :- - ( rcb( X, Status, Violated) -> % have a culprit - rcbl_status( Status, X, Continuation, Bind0,BindT, Violated) - ; - rcbl( Continuation, Bind0,BindT) - ). - -% -% reconsider one element of the basis -% later: lift the binds -% -reconsider( X) :- - rcb( X, Status, Violated), - !, - rcbl_status( Status, X, [], Binds,[], Violated), - export_binding( Binds). -reconsider( _). - -% -% Find a basis variable out of its bound or at its bound -% Try to move it into whithin its bound -% a) impossible -> fail -% b) optimum at the bound -> implied value -% c) else look at the remaining basis variables -% -rcb( X, Status, Violated) :- - get_atts( X, [lin(Lin),type(Type)]), - decompose( Lin, H, R, I), - ( Type = t_l(L), - arith_eval( R+I =< L), - Violated = l(L), - inc_step( H, Status) - - ; Type = t_u(U), - arith_eval( R+I >= U), - Violated = u(U), - dec_step( H, Status) - - ; Type = t_lu(L,U), - arith_eval( R+I, At), - ( - arith_eval( At =< L), - Violated = l(L), - inc_step( H, Status) - ; - arith_eval( At >= U), - Violated = u(U), - dec_step( H, Status) - ) - % - % don't care for other types - % - ). - -rcbl_status( optimum, X, Cont, B0,Bt, Violated) :- rcbl_opt( Violated, X, Cont, B0,Bt). -rcbl_status( applied, X, Cont, B0,Bt, Violated) :- rcbl_app( Violated, X, Cont, B0,Bt). -rcbl_status( unlimited(Indep,DepT), X, Cont, B0,Bt, Violated) :- rcbl_unl( Violated, X, Cont, B0,Bt, Indep, DepT). - -% -% Might reach optimum immediately without changing the basis, -% but in general we must assume that there were pivots. -% If the optimum meets the bound, we backsubstitute the implied -% value, solve will call us again to check for further implied -% values or unsatisfiability in the rank increased system. -% -rcbl_opt( l(L), X, Continuation, B0,B1) :- - get_atts( X, [lin(Lin),strictness(Strict),type(Type)]), - decompose( Lin, _, R, I), - arith_eval( R+I, Opt), - case_signum( L-Opt, - ( - narrow_u( Type, X, Opt), % { X =< Opt } - rcbl( Continuation, B0,B1) - ), - ( - Strict /\ 2'10 =:= 0, % meets lower - arith_eval( -Opt, Mop), - normalize_scalar( Mop, MopN), - add_linear_11( MopN, Lin, Lin1), - decompose( Lin1, Hom, _, Inhom), - %vsc: added -> (01/06/06) - ( Hom = [] -> rcbl( Continuation, B0,B1) % would not callback - ; Hom = [_|_] -> solve( Hom, Lin1, Inhom, B0,B1) - ) - ), - fail - ). -rcbl_opt( u(U), X, Continuation, B0,B1) :- - get_atts( X, [lin(Lin),strictness(Strict),type(Type)]), - decompose( Lin, _, R, I), - arith_eval( R+I, Opt), - case_signum( U-Opt, - fail, - ( - Strict /\ 2'01 =:= 0, % meets upper - arith_eval( -Opt, Mop), - normalize_scalar( Mop, MopN), - add_linear_11( MopN, Lin, Lin1), - decompose( Lin1, Hom, _, Inhom), - %vsc: added -> (01/06/06) - ( Hom = [] -> rcbl( Continuation, B0,B1) % would not callback - ; Hom = [_|_] -> solve( Hom, Lin1, Inhom, B0,B1) - ) - ), - ( - narrow_l( Type, X, Opt), % { X >= Opt } - rcbl( Continuation, B0,B1) - )). - -% -% Basis has already changed when this is called -% -rcbl_app( l(L), X, Continuation, B0,B1) :- - get_atts( X, lin(Lin)), - decompose( Lin, H, R, I), - ( arith_eval( R+I > L) -> % within bound now - rcbl( Continuation, B0,B1) - ; - % arith_eval( R+I, Val), print( rcbl_app(X:L:Val)), nl, - inc_step( H, Status), - rcbl_status( Status, X, Continuation, B0,B1, l(L)) - ). -rcbl_app( u(U), X, Continuation, B0,B1) :- - get_atts( X, lin(Lin)), - decompose( Lin, H, R, I), - ( arith_eval( R+I < U) -> % within bound now - rcbl( Continuation, B0,B1) - ; - dec_step( H, Status), - rcbl_status( Status, X, Continuation, B0,B1, u(U)) - ). - -% -% This is never called for a t_lu culprit -% -rcbl_unl( l(L), X, Continuation, B0,B1, Indep, DepT) :- - pivot_a( X, Indep, t_L(L), DepT), % changes the basis - rcbl( Continuation, B0,B1). -rcbl_unl( u(U), X, Continuation, B0,B1, Indep, DepT) :- - pivot_a( X, Indep, t_U(U), DepT), % changes the basis - rcbl( Continuation, B0,B1). - -narrow_u( t_u(_), X, U) :- put_atts( X, type(t_u(U))). -narrow_u( t_lu(L,_), X, U) :- put_atts( X, type(t_lu(L,U))). - -narrow_l( t_l(_), X, L) :- put_atts( X, type(t_l(L))). -narrow_l( t_lu(_,U), X, L) :- put_atts( X, type(t_lu(L,U))). - -% ----------------------------------- dump ------------------------------------- - -dump_var( t_none, V, I,H) --> !, - ( { H=[W*K],V==W,arith_eval(I=:=0),arith_eval(K=:=1) } -> % indep var - [] - ; - { nf2sum( H, I, Sum) }, - [ V = Sum ] - ). -dump_var( t_L(L), V, I,H) --> !, dump_var( t_l(L), V, I,H). -dump_var( t_l(L), V, I,H) --> !, - { - H= [_*K|_], % avoid 1 >= 0 - get_atts( V, strictness(Strict)), - Sm is Strict /\ 2'10, - arith_eval( 1/K, Kr), - arith_eval( Kr*(L-I), Li), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum), - ( arith_eval( K > 0) -> - dump_strict( Sm, Sum >= Li, Sum > Li, Result) - ; - dump_strict( Sm, Sum =< Li, Sum < Li, Result) - ) - }, - [ Result ]. -dump_var( t_U(U), V, I,H) --> !, dump_var( t_u(U), V, I,H). -dump_var( t_u(U), V, I,H) --> !, - { - H= [_*K|_], % avoid 0 =< 1 - get_atts( V, strictness(Strict)), - Sm is Strict /\ 2'01, - arith_eval( 1/K, Kr), - arith_eval( Kr*(U-I), Ui), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum), - ( arith_eval( K > 0) -> - dump_strict( Sm, Sum =< Ui, Sum < Ui, Result) - ; - dump_strict( Sm, Sum >= Ui, Sum > Ui, Result) - ) - }, - [ Result ]. -dump_var( t_Lu(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( t_lU(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( t_lu(L,U), V, I,H) --> !, dump_var( t_l(L), V,I,H), - dump_var( t_U(U), V,I,H). -dump_var( T, V, I,H) --> - [ V:T:I+H ]. - -dump_strict( 0, Result, _, Result). -dump_strict( 1, _, Result, Result). -dump_strict( 2, _, Result, Result). - -dump_nz( _, H, I) --> - { - H = [_*K|_], - arith_eval( 1/K, Kr), - arith_eval( -Kr*I, I1), - mult_hom( H, Kr, H1), - arith_eval( 0, Z), nf2sum( H1, Z, Sum) - }, - [ Sum =\= I1 ]. diff --git a/CLPQR/clpqr/compenv.pl b/CLPQR/clpqr/compenv.pl deleted file mode 100644 index e91933936..000000000 --- a/CLPQR/clpqr/compenv.pl +++ /dev/null @@ -1,86 +0,0 @@ -% Copyright (C) 1994, Swedish Institute of Computer Science. - -% Provides compile time environment for fcompiling clpq/clpr - -:- meta_predicate nfq:geler(?,:). -:- meta_predicate nfr:geler(?,:). -:- meta_predicate clpq:wait_linear(?,?,:). -:- meta_predicate clpr:wait_linear(?,?,:). - -% -% Don't report export of private predicates from clpq -% -:- multifile - user:portray_message/2. - -:- dynamic - user:portray_message/2. -% -user:portray_message( warning, import(_,_,From,private)) :- - clpqr( From). - -clpqr( clpq). -clpqr( clpr). - -env_fcompile( Name, Arith) :- - compile_time_env( Name, Arith, Module), - fcompile( Module:Name). - -compile_time_env(File, Arith, Module) :- - file_mod(Arith, File, Module), - load_expansions(Module, Arith). - -load_expansions(user, _). -load_expansions(arith_q, _). -load_expansions(arith_r, _). -load_expansions(classq, _) :- [class]. % atts -load_expansions(classr, _) :- [class]. % atts -load_expansions(geler_q, _) :- [geler]. % atts -load_expansions(geler_r, _) :- [geler]. % atts -load_expansions(nfq, Arith) :- - nfq:[Arith]. % macros -load_expansions(nfr, Arith) :- - nfr:[Arith]. % macros -load_expansions(clpr, Arith) :- - clpr:[Arith], % macros - clpr:[itf3], % atts - clpr:[store]. % macros -load_expansions(clpq, Arith) :- - clpq:[Arith], % macros - clpq:[itf3], % atts - clpq:[store]. % macros - -file_mod(arith_q, arith, arith_q). -file_mod(arith_r, arith, arith_r). -file_mod(arith_q, arith_q, arith_q). -file_mod(arith_r, arith_r, arith_r). -file_mod(arith_q, bb, clpq). -file_mod(arith_r, bb, clpr). -file_mod(arith_q, bv, clpq). -file_mod(arith_r, bv, clpr). -file_mod(arith_q, class, classq). -file_mod(arith_r, class, classr). -file_mod(_, compenv, user). -file_mod(arith_q, dump, clpq). -file_mod(arith_r, dump, clpr). -file_mod(arith_q, fourmotz, clpq). -file_mod(arith_r, fourmotz, clpr). -file_mod(arith_q, geler, geler_q). -file_mod(arith_r, geler, geler_r). -file_mod(arith_q, ineq, clpq). -file_mod(arith_r, ineq, clpr). -file_mod(arith_q, itf3, clpq). -file_mod(arith_r, itf3, clpr). -file_mod(arith_q, nf, nfq). -file_mod(arith_r, nf, nfr). -file_mod(arith_q, nfq, nfq). -file_mod(arith_r, nfr, nfr). -file_mod(arith_q, ordering, classq). -file_mod(arith_r, ordering, classr). -file_mod(arith_q, project, clpq). -file_mod(arith_r, project, clpr). -file_mod(arith_q, redund, clpq). -file_mod(arith_r, redund, clpr). -file_mod(arith_q, store, clpq). -file_mod(arith_r, store, clpr). - diff --git a/CLPQR/clpqr/dump.pl b/CLPQR/clpqr/dump.pl deleted file mode 100644 index 54e957c7b..000000000 --- a/CLPQR/clpqr/dump.pl +++ /dev/null @@ -1,147 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: dump.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -/* -dump( +Target, ?NewVars, ?CodedAnswer) - -where Target and NewVars are lists of variables of equal length and -CodedAnswer is the term representation of the projection of constraints -onto the target variables where the target variables are replaced by -the corresponding variables from NewVars. -*/ - -:- use_module( library(terms), [term_variables/2]). - -:- use_module( library(assoc), - [ - empty_assoc/1, - get_assoc/3, - put_assoc/4, - assoc_to_list/2 - ]). - -dump( Target, NewVars, Constraints) :- - ( - ( proper_varlist( Target) -> - true - ; - raise_exception(instantiation_error(dump(Target,NewVars,Constraints),1)) - ), - ordering( Target), - related_linear_vars( Target, All), - nonlin_crux( All, Nonlin), - project_attributes( Target, All), - related_linear_vars( Target, Again), % project drops/adds vars - all_attribute_goals( Again, Gs, Nonlin), - empty_assoc( D0), - mapping( Target, NewVars, D0,D1), % late (AVL suffers from put_atts) - copy( Gs, Copy, D1,_), % strip constraints - bb_put( copy, NewVars/Copy), - fail % undo projection - ; - bb_delete( copy, NewVars/Constraints) % garbage collect - ). - -proper_varlist( X) :- var( X), !, fail. -proper_varlist( []). -proper_varlist( [X|Xs]) :- - var( X), - proper_varlist( Xs). - -related_linear_vars( Vs, All) :- - empty_assoc( S0), - related_linear_sys( Vs, S0,Sys), - related_linear_vars( Sys, All, []). - -related_linear_sys( [], S0,L0) :- assoc_to_list( S0, L0). -related_linear_sys( [V|Vs], S0,S2) :- - ( get_atts( V, class(C)) -> - put_assoc( C, S0, C, S1) - ; - S1 = S0 - ), - related_linear_sys( Vs, S1,S2). - -related_linear_vars( []) --> []. -related_linear_vars( [S-_|Ss]) --> - { - class_allvars( S, Otl) - }, - cpvars( Otl), - related_linear_vars( Ss). - -cpvars( Xs) --> {var(Xs)}, !. -cpvars( [X|Xs]) --> - ( {var(X)} -> [X] ; [] ), - cpvars( Xs). - -nonlin_crux( All, Gss) :- - collect_nonlin( All, Gs, []), % destructive - this_linear_solver( Solver), - nonlin_strip( Gs, Solver, Gss). - -nonlin_strip( [], _, []). -nonlin_strip( [M:What|Gs], Solver, Res) :- - ( M == Solver -> - ( What = {G} -> - Res = [G|Gss] - ; - Res = [What|Gss] - ) - ; - Res = Gss - ), - nonlin_strip( Gs, Solver, Gss). - -all_attribute_goals( []) --> []. -all_attribute_goals( [V|Vs]) --> - dump_linear( V, toplevel), - dump_nonzero( V, toplevel), - all_attribute_goals( Vs). - -mapping( [], [], D0,D0). -mapping( [T|Ts], [N|Ns], D0,D2) :- - put_assoc( T, D0, N, D1), - mapping( Ts, Ns, D1,D2). - -copy( Term, Copy, D0,D1) :- var( Term), - ( get_assoc( Term, D0, New) -> - Copy = New, - D1 = D0 - ; - put_assoc( Term, D0, Copy, D1) - ). -copy( Term, Copy, D0,D1) :- nonvar( Term), - functor( Term, N, A), - functor( Copy, N, A), - copy( A, Term, Copy, D0,D1). - -copy( 0, _, _, D0,D0) :- !. -copy( 1, T, C, D0,D1) :- !, - arg( 1, T, At1), - arg( 1, C, Ac1), - copy( At1, Ac1, D0,D1). -copy( 2, T, C, D0,D2) :- !, - arg( 1, T, At1), - arg( 1, C, Ac1), - copy( At1, Ac1, D0,D1), - arg( 2, T, At2), - arg( 2, C, Ac2), - copy( At2, Ac2, D1,D2). -copy( N, T, C, D0,D2) :- - arg( N, T, At), - arg( N, C, Ac), - copy( At, Ac, D0,D1), - N1 is N-1, - copy( N1, T, C, D1,D2). - -end_of_file. diff --git a/CLPQR/clpqr/examples/README b/CLPQR/clpqr/examples/README deleted file mode 100644 index e70747dea..000000000 --- a/CLPQR/clpqr/examples/README +++ /dev/null @@ -1,3 +0,0 @@ -The SESSION directory contains some recorded clp(q,r) sessions. -They were primarily used for regression testing, but they can -get you started on how to interact with the solver(s). \ No newline at end of file diff --git a/CLPQR/clpqr/examples/SESSION/010 b/CLPQR/clpqr/examples/SESSION/010 deleted file mode 100644 index c788bee63..000000000 --- a/CLPQR/clpqr/examples/SESSION/010 +++ /dev/null @@ -1,66 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/air')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/air...} -{Warning: [T] - singleton variables in comp/3 in lines 27-28} -{Warning: [X] - singleton variables in zero/1 in lines 38-40} -{Warning: [T] - singleton variables in bal_side/3 in lines 45-50} -{Warning: [X] - singleton variables in add_species/4 in lines 56-57} -{Warning: [NUM] - singleton variables in add_elements/5 in lines 57-60} -{Warning: [PROP,X] - singleton variables in add_elements/5 in lines 68-70} -{Warning: [F1] - singleton variables in go/0 in lines 76-87} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/air consulted, 110 msec 10384 bytes} - -yes -| ?- go. -species air -molecule n2 -molecule o2 -atom o -species fuel -molecule c -atom c -species flue -molecule co2 -atom c -atom o -molecule co -atom c -atom o -molecule o2 -atom o -molecule n2 -With base of 1.000000 mol of fuel -air (just to burn the carbon) = 5.317460 mol -flue (mol) :6.666667 - -species air -molecule n2 -molecule o2 -atom o -species fuel -molecule c -atom c -species full_comb -molecule co2 -atom c -atom o -molecule n2 -Compared with theoretical air (for complete combustion): - 4.761905 mol -Excess = 11.666667% - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/011 b/CLPQR/clpqr/examples/SESSION/011 deleted file mode 100644 index fceb9c513..000000000 --- a/CLPQR/clpqr/examples/SESSION/011 +++ /dev/null @@ -1,64 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/amplif')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/amplif...} -{Warning: [Collector_Currents] - singleton variables in dc_analysis/3 in lines 1-31} -{Warning: [Type,Vc] - singleton variables in component_ss/6 in lines 70-75} -{Warning: [V1,V2] - singleton variables in component_dc/7 in lines 89-90} -{Warning: [Vbreak,Vreak] - singleton variables in component_dc/7 in lines 93-96} -{Warning: [Vbreak] - singleton variables in diode_state/5 in lines 96-104} -{Warning: [Beta] - singleton variables in transistor_state/7 in lines 122-127} -{Warning: [Beta] - singleton variables in transistor_state/7 in lines 127-133} -{Warning: [Beta,Vc,Vcesat] - singleton variables in transistor_state/7 in lines 133-139} -{Warning: [Beta,Vc,Vcesat] - singleton variables in transistor_state/7 in lines 139-144} -{Warning: [Points] - singleton variables in print_circuit/1 in lines 202-205} -{Warning: [R1,R2,Rc,Re] - singleton variables in circuit/6 in lines 233-244} -{Warning: [C1,C2,C3,R1,R2,Rc,Re] - singleton variables in circuit/6 in lines 244-255} -{Warning: [C1,C3,R1,R2,Re] - singleton variables in circuit/6 in lines 255-264} -{Warning: [St1,St2,St3,St4,State] - singleton variables in go1/0 in lines 264-274} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/amplif consulted, 360 msec 22640 bytes} - -yes -| ?- go1. -cc1 at 15 [0.0,0.14400000000000002,0.0,-0.14400000000000002] -cc2 at -12 [-0.114,0.114] -gnd at 0 [0.0,-0.030000000000000013,0.030000000000000013] -a at 0.6 [0.114,-0.14400000000000002,0.0,0.030000000000000013] -p1 at 0 [0.114,-0.114] -b at -0.6 [0.0,0.114,-0.114] -c at 15 [0.0,0.0] - diode at d1 [di1,forward] - diode at d2 [di1,reverse] - resistor at r1 100 - diode at d3 [di1,forward] - diode at d4 [di1,forward] - resistor at r2 100 - transistor at tr [npn,tr0,cutoff] - resistor at rc 100 - -yes -| ?- go2. -Stab 0.0019465 -Outresist 0.85711 - capacitor at c1 _1483 - resistor at r1 100 - resistor at r2 100 - transistor at tr [npn,tr0,active] - resistor at re 100 - capacitor at c3 _1405 -[[capacitor,c1,_1483,[in,b]],[resistor,r1,100.0,[b,cc1]],[resistor,r2,100.0,[b,gnd]],[transistor,tr,[npn,tr0,active],[b,cc1,e]],[resistor,re,100.0,[e,gnd]],[capacitor,c3,_1405,[e,out]]] - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/012 b/CLPQR/clpqr/examples/SESSION/012 deleted file mode 100644 index dcc6c666e..000000000 --- a/CLPQR/clpqr/examples/SESSION/012 +++ /dev/null @@ -1,27 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 50 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 50 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 130 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/complex')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/complex...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/complex consulted, 30 msec 1760 bytes} - -yes -| ?- go. - -[32,88,32,61,32]c(1.0,1.0) -[32,89,32,61,32]c(2.0,2.0) -[32,90,32,61,32]c(0.0,4.0) - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/013 b/CLPQR/clpqr/examples/SESSION/013 deleted file mode 100644 index 097956fe5..000000000 --- a/CLPQR/clpqr/examples/SESSION/013 +++ /dev/null @@ -1,138 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/critical')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/critical...} -{Warning: [End] - singleton variables in cpm/2 in lines 62-67} -{Warning: [Es,From,Lc,T] - singleton variables in buildv/3 in lines 81-83} -{Warning: [H] - singleton variables in buildv/3 in lines 83-85} -{Warning: [Es,Lc,T,To] - singleton variables in buildv/3 in lines 85-87} -{Warning: [H] - singleton variables in buildv/3 in lines 87-89} -{Warning: [H] - singleton variables in addedg/3 in lines 91-93} -{Warning: [T] - singleton variables in addedg/3 in lines 93-94} -{Warning: [H] - singleton variables in addedg/3 in lines 94-96} -{Warning: [I] - singleton variables in early_late/4 in lines 102-106} -{Warning: [I] - singleton variables in early_late/3 in lines 108-112} -{Warning: [End] - singleton variables in setearly/5 in lines 118-121} -{Warning: [Last] - singleton variables in setlate/4 in lines 128-131} -{Warning: [T] - singleton variables in getnode/4 in lines 136-139} -{Warning: [H] - singleton variables in getnode/4 in lines 139-141} -{Warning: [G] - singleton variables in analyse/2 in lines 141-148} -{Warning: [I] - singleton variables in analyse/2 in lines 148-151} -{Warning: [Lci] - singleton variables in compute/9 in lines 157-166} -{Warning: [From] - singleton variables in print_node/1 in lines 176-180} -{Warning: [From] - singleton variables in print_node/1 in lines 186-191} - ->>> Sample goals: go1/0, go2/0, go3/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/critical consulted, 330 msec 16368 bytes} - -yes -| ?- go1. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 3 2 3 2 0 -n1 n3 2 0 2 0 0 * --------------------------------------------------- - n2 3 5 --------------------------------------------------- -n2 n4 2 5 5 2 2 --------------------------------------------------- - n3 2 2 --------------------------------------------------- -n3 n4 5 2 7 0 0 * --------------------------------------------------- -END NODE n4 7 7 - -yes -| ?- go2. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- - n5 8 8 --------------------------------------------------- -n5 n6 9 8 17 0 0 * -n5 n7 5 12 13 4 4 --------------------------------------------------- - n6 17 17 --------------------------------------------------- -n6 n7 0 17 17 0 0 * -n6 n8 4 19 21 2 2 --------------------------------------------------- - n7 17 17 --------------------------------------------------- -n7 n8 6 17 23 0 0 * --------------------------------------------------- - n4 3 8 --------------------------------------------------- -n4 n7 4 13 7 10 10 -n4 n5 0 8 3 5 5 -n4 n8 3 20 6 17 17 --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 2 4 2 4 0 -n1 n3 6 0 6 0 0 * -n1 n4 3 5 3 5 0 --------------------------------------------------- - n2 2 6 --------------------------------------------------- -n2 n3 0 6 2 4 4 -n2 n5 1 7 3 5 5 -n2 n6 4 13 6 11 11 --------------------------------------------------- - n3 6 6 --------------------------------------------------- -n3 n5 2 6 8 0 0 * --------------------------------------------------- -END NODE n8 23 23 - -yes -| ?- go3. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 4 0 4 0 0 * -n1 n3 3 4 3 4 2 -n1 n4 4 6 4 6 0 --------------------------------------------------- - n2 4 4 --------------------------------------------------- -n2 n5 7 4 11 0 0 * -n2 n3 1 6 5 2 0 -n2 n7 8 8 12 4 4 --------------------------------------------------- - n3 5 7 --------------------------------------------------- -n3 n5 4 7 9 2 2 --------------------------------------------------- - n4 4 10 --------------------------------------------------- -n4 n6 2 10 6 6 6 --------------------------------------------------- - n5 11 11 --------------------------------------------------- -n5 n6 1 11 12 0 0 * -n5 n7 3 13 14 2 2 --------------------------------------------------- -END NODE n7 16 16 --------------------------------------------------- - n6 12 12 --------------------------------------------------- -n6 n7 4 12 16 0 0 * - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/014 b/CLPQR/clpqr/examples/SESSION/014 deleted file mode 100644 index 3eab3f105..000000000 --- a/CLPQR/clpqr/examples/SESSION/014 +++ /dev/null @@ -1,25 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/fib')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/fib...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/fib consulted, 10 msec 1664 bytes} - -yes -| ?- go. -forward: fib(10) = 89 -backward: fib(10) = 89 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/015 b/CLPQR/clpqr/examples/SESSION/015 deleted file mode 100644 index 7112041e3..000000000 --- a/CLPQR/clpqr/examples/SESSION/015 +++ /dev/null @@ -1,29 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 50 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 150 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/findroot')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/findroot...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/findroot consulted, 30 msec 4528 bytes} - -yes -| ?- go. -1.70000000 -0.44834437 -0.91953538 -0.99701354 -0.99999555 -1.00000000 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/016 b/CLPQR/clpqr/examples/SESSION/016 deleted file mode 100644 index bfc9ac458..000000000 --- a/CLPQR/clpqr/examples/SESSION/016 +++ /dev/null @@ -1,35 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/invert')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/invert...} -{Warning: [C] - singleton variables in allvec/2 in lines 21-23} -{Warning: [H] - singleton variables in mylength/2 in lines 27-28} -{Warning: [H] - singleton variables in mylength/2 in lines 28-31} -{Warning: [A] - singleton variables in rowtocol/2 in lines 50-51} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/invert consulted, 100 msec 8288 bytes} - -yes -| ?- go. - NR = - 0.2917 0.0417 -0.2083 - -0.0833 0.4167 -0.0833 - 0.0417 -0.3750 0.2083 - T = - 1.0000 0.0000 0.0000 - 0.0000 1.0000 0.0000 - 0.0000 0.0000 1.0000 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/017 b/CLPQR/clpqr/examples/SESSION/017 deleted file mode 100644 index b26fd262d..000000000 --- a/CLPQR/clpqr/examples/SESSION/017 +++ /dev/null @@ -1,53 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/laplace')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/laplace...} -{Warning: [BL,TL] - singleton variables in laplace_vec/3 in lines 24-28} -{Warning: [B11,B12,B13,B14,B21,B24,B31,B34,B42,B43,M22,M23,M32,M33] - singleton variables in go2/0 in lines 58-81} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/laplace consulted, 100 msec 7408 bytes} - -yes -| ?- go1. - - 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 - 100.00 51.11 32.52 24.56 21.11 20.12 21.11 24.56 32.52 51.11 100.00 - 100.00 71.91 54.41 44.63 39.74 38.26 39.74 44.63 54.41 71.91 100.00 - 100.00 82.12 68.59 59.80 54.97 53.44 54.97 59.80 68.59 82.12 100.00 - 100.00 87.97 78.03 71.00 66.90 65.56 66.90 71.00 78.03 87.97 100.00 - 100.00 91.71 84.58 79.28 76.07 75.00 76.07 79.28 84.58 91.71 100.00 - 100.00 94.30 89.29 85.47 83.10 82.30 83.10 85.47 89.29 94.30 100.00 - 100.00 96.20 92.82 90.20 88.56 88.00 88.56 90.20 92.82 96.20 100.00 - 100.00 97.67 95.59 93.96 92.93 92.58 92.93 93.96 95.59 97.67 100.00 - 100.00 98.89 97.90 97.12 96.63 96.46 96.63 97.12 97.90 98.89 100.00 - 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 - -yes -| ?- go2. - -yes -| ?- laplace([ - [B11, B12, B13, B14], - [B21, M22, M23, B24], - [B31, M32, M33, B34], - [B44, B42, B43, B44] - ]). - -{M32= -(B12)-B21+4.0*M22-M23}, -{M33= -(M22)+4.0*M23-B13-B24}, -{B42= -4.0*B12-4.0*B21+16.0*M22-8.0*M23+B13+B24-B31}, -{B43=B12+B21-8.0*M22+16.0*M23-4.0*B13-4.0*B24-B34} ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/018 b/CLPQR/clpqr/examples/SESSION/018 deleted file mode 100644 index c0d01da49..000000000 --- a/CLPQR/clpqr/examples/SESSION/018 +++ /dev/null @@ -1,46 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 130 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/mortgage')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/mortgage...} -{Warning: [Int] - singleton variables in go4/0 in lines 45-51} - ->>> Sample goals: go1/0, go2/0, go3/0, go4/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/mortgage consulted, 40 msec 4992 bytes} - -yes -| ?- go1. -Forward: MP = 1721.65 -Backward: P = 120000 - -yes -| ?- go2. - -yes -| ?- mg(P,120,0.01,0,MP), dump([P,MP]). - -{P=69.7005220313972*MP} ? - -yes -| ?- mg(P,120,0.01,B,MP), dump([P,B,MP]). - -{P=0.30299477968602706*B+69.7005220313972*MP} ? - -yes -| ?- mg(999, 3, Int, 0, 400), dump. - -nonlin:{_B-_B*Int+_A+400.0=0.0}, -nonlin:{_A-_A*Int+400.0=0.0}, -{_B=599.0+999.0*Int} ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/019 b/CLPQR/clpqr/examples/SESSION/019 deleted file mode 100644 index 439ecdff0..000000000 --- a/CLPQR/clpqr/examples/SESSION/019 +++ /dev/null @@ -1,76 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 130 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/option')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/option...} -{Warning: [B,C,P,X] - singleton variables in table/13 in lines 47-54} -{Warning: [B,P,S] - singleton variables in table/13 in lines 54-55} -{Warning: [B,C,S] - singleton variables in table/13 in lines 55-56} -{Warning: [C,P,S,X] - singleton variables in table/13 in lines 56-57} - ->>> Sample goals (some with multiple answers): - go1(W), go2(S, W), go3(S, W), go4(S, W), go5(S, W) -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/option consulted, 160 msec 10032 bytes} - -yes -| ?- go1(W). - -W = -4.75 ? ; - -no -| ?- go2(S,W). - -W = 5.25, -{S>=0.0}, -{S<50.0} ? ; - -{W>5.0}, -{S=55.25-W}, -{W=<5.25} ? ; - -no -| ?- go3(S,W). - -{W>=10.0}, -{S=37.4-W}, -{W=<37.4} ? ; - -{W>=10.0}, -{S=62.6+W} ? ; - -no -| ?- go4(S,W). - -W = 5.699999999999999, -{S>=0.0}, -{S<20.0} ? ; - -{S>=20.0}, -{S<40.0}, -{W=25.7-S} ? ; - -W = -14.3, -{S>=40.0}, -{S<60.0} ? ; - -{S>=60.0}, -{S<80.0}, -{W= -74.3+S} ? ; - -W = 5.699999999999999, -{S>=80.0} ? ; - -no -| ?- go5(S,W). - -no -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/020 b/CLPQR/clpqr/examples/SESSION/020 deleted file mode 100644 index 42df6d02d..000000000 --- a/CLPQR/clpqr/examples/SESSION/020 +++ /dev/null @@ -1,64 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/pictures')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/pictures...} -{Warning: [DotDashInvis,Text] - singleton variables in box/3 in lines 66-73} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/pictures consulted, 110 msec 12768 bytes} - -yes -| ?- go1. -.PS 2i -line from 3.2,1.8 to 0.688979,1.17224 -line from 0.688979,1.17224 to 2.30239,4.19362 -line from 2.30239,4.19362 to 3.2,1.8 -line from 0,1 to 4,2 dashed -line from 3.5,1 to 2,5 dashed -line from 0.33,0.5 to 3,5.5 dashed - " c1 " at 0,1 rjust - " c2 " at 3.5,1 rjust - " c3 " at 0.33,0.5 rjust -.PE - -yes -| ?- go2. -.PS 3i -line from 0,0 to 8,10 -line from 8,10 to 10,10 -line from 10,10 to 10,1 -line from 10,1 to 0,0 -line from 4,5 to 9,10 dashed -line from 9,10 to 10,5.5 dashed -line from 10,5.5 to 5,0.5 dashed -line from 5,0.5 to 4,5 dashed -line from 0,20 to 0,15 -line from 0,15 to 10,15 -line from 10,15 to 10,20 -line from 10,20 to 0,20 -line from 0,17.5 to 5,15 dashed -line from 5,15 to 10,17.5 dashed -line from 10,17.5 to 5,20 dashed -line from 5,20 to 0,17.5 dashed -line from 5,30 to 10,23 -line from 10,23 to 15,30 -line from 15,30 to 10,25 -line from 10,25 to 5,30 -line from 7.5,26.5 to 12.5,26.5 dashed -line from 12.5,26.5 to 12.5,27.5 dashed -line from 12.5,27.5 to 7.5,27.5 dashed -line from 7.5,27.5 to 7.5,26.5 dashed -.PE - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/021 b/CLPQR/clpqr/examples/SESSION/021 deleted file mode 100644 index 57c0af201..000000000 --- a/CLPQR/clpqr/examples/SESSION/021 +++ /dev/null @@ -1,55 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/rkf45')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rkf45...} -{Warning: [Abserr,Incr,Mode,T,Tend,Y] - singleton variables in solve1/2 in lines 77-81} -{Warning: [Incr,Mode,Relerr,T,Tend,Y] - singleton variables in solve1/2 in lines 87-90} -{Warning: [Mode] - singleton variables in solve1/2 in lines 95-102} -{Warning: [Hmode,Out] - singleton variables in iter1/2 in lines 141-148} -{Warning: [Hmode,Out] - singleton variables in stop_or_iter1/5 in lines 153-157} -{Warning: [Sum] - singleton variables in stop_or_iter1/5 in lines 157-163} -{Warning: [Y,Yp] - singleton variables in stop_or_iter1/5 in lines 163-171} -{Warning: [Out] - singleton variables in check_h/2 in lines 191-194} -{Warning: [Work] - singleton variables in check_out/3 in lines 204-209} -{Warning: [Relerr] - singleton variables in check_out/3 in lines 209-215} -{Warning: [Kop] - singleton variables in check_out/3 in lines 231-235} -{Warning: [Other] - singleton variables in check_out/3 in lines 244-246} -{Warning: [Yp] - singleton variables in set_maxtol/6 in lines 289-293} -{Warning: [H] - singleton variables in set_h1/5 in lines 298-305} -{Warning: [S,Y,Yp] - singleton variables in check_err/11 in lines 453-456} -{Warning: [S,Y] - singleton variables in check_err/11 in lines 456-462} -{Warning: [T] - singleton variables in eval/3 in lines 473-478} -{Warning: [Y3,Y4] - singleton variables in user_output/2 in lines 478-481} -{Warning: [Abs,H,Incr,Kop,Nfe,Rer,T,Tend,Tout,Y,Yp] - singleton variables in user_error/3 in lines 481-485} -{Warning: [Abs,H,Incr,Kop,Nfe,Rer,T,Tend,Tout,Y,Yp] - singleton variables in user_error/3 in lines 485-489} -{Warning: [Abs,H,Incr,Kop,Nfe,Rer,T,Tend,Tout,Y,Yp] - singleton variables in user_error/3 in lines 489-493} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rkf45 consulted, 590 msec 41376 bytes} - -yes -| ?- go. -Point 0.00000 : 0.75000 0.00000 -Point 0.50000 : 0.61969 0.47793 -Point 1.00000 : 0.29417 0.81233 -Point 1.50000 : -0.10556 0.95809 -Point 2.00000 : -0.49076 0.93977 -Point 2.50000 : -0.81440 0.79929 -Point 3.00000 : -1.05440 0.57522 - -Iteration finished ------------------- - 439 derivative evaluations - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/022 b/CLPQR/clpqr/examples/SESSION/022 deleted file mode 100644 index 17834458a..000000000 --- a/CLPQR/clpqr/examples/SESSION/022 +++ /dev/null @@ -1,160 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 50 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/rlc')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rlc...} -{Warning: [Comp,Num,X] - singleton variables in get_node_vars/2 in lines 22-26} -{Warning: [V] - singleton variables in insert/3 in lines 36-37} -{Warning: [W] - singleton variables in solve/5 in lines 43-47} -{Warning: [N,V] - singleton variables in zero_currents/1 in lines 47-52} -{Warning: [Vs] - singleton variables in ground_nodes/2 in lines 69-70} -{Warning: [I,Vs] - singleton variables in ground_node/2 in lines 70-71} -{Warning: [I,N1,V] - singleton variables in ground_node/2 in lines 71-72} -{Warning: [W] - singleton variables in iv_reln/5 in lines 85-89} -{Warning: [I,W] - singleton variables in iv_reln/5 in lines 89-89} -{Warning: [V,W] - singleton variables in iv_reln/5 in lines 89-90} -{Warning: [I,L,W] - singleton variables in iv_reln/5 in lines 95-96} -{Warning: [L,V,W] - singleton variables in iv_reln/5 in lines 96-97} -{Warning: [W] - singleton variables in iv_reln/5 in lines 97-98} -{Warning: [I4,NV4,W] - singleton variables in addcomp/5 in lines 111-127} -{Warning: [W] - singleton variables in addcomp/5 in lines 129-145} -{Warning: [L2,X,Y] - singleton variables in subst/4 in lines 150-152} -{Warning: [Im] - singleton variables in c_real/2 in lines 169-171} -{Warning: [Re] - singleton variables in c_imag/2 in lines 171-173} -{Warning: [Ls] - singleton variables in selective_print/2 in lines 190-191} -{Warning: [Comp,Nodes,Num,X] - singleton variables in print_nodes/3 in lines 198-200} -{Warning: [Heading_flag,N1] - singleton variables in print_nodes/3 in lines 200-201} -{Warning: [Comp,Nodes,Num,X] - singleton variables in print_comps/2 in lines 205-207} -{Warning: [Num] - singleton variables in print_comps/2 in lines 207-208} -{Warning: [N,X] - singleton variables in heading/2 in lines 212-213} -{Warning: [I,Ls,V] - singleton variables in member/2 in lines 213-215} -{Warning: [I,N2,V] - singleton variables in member/2 in lines 215-217} -{Warning: [R3,W] - singleton variables in go2/0 in lines 285-359} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rlc consulted, 410 msec 26416 bytes} - -yes -| ?- go1. -resistor r1: 10 Ohms - Node n1 - Voltage c(10.0,0.0) - Current c(0.5524861878453038,-0.4972375690607733) - Node n2 - Voltage c(4.475138121546962,4.972375690607734) - Current c(-0.5524861878453038,0.4972375690607733) - -resistor r3: 10 Ohms - Node n1 - Voltage c(10.0,0.0) - Current c(0.5524861878453038,-0.49723756906077343) - Node n4 - Voltage c(4.475138121546961,4.972375690607734) - Current c(-0.5524861878453038,0.49723756906077343) - -inductor l1: 0.9 Henrys - Node n2 - Voltage c(4.475138121546962,4.972375690607734) - Current c(0.5524861878453038,-0.49723756906077354) - Node n7 - Voltage c(0.0,0.0) - Current c(-0.5524861878453038,0.49723756906077354) - -inductor l3: 0.9 Henrys - Node n4 - Voltage c(4.475138121546961,4.972375690607734) - Current c(0.5524861878453039,-0.49723756906077354) - Node n7 - Voltage c(0.0,0.0) - Current c(-0.5524861878453039,0.49723756906077354) - -capacitor c8: 0.007 Farads - Node n4 - Voltage c(4.475138121546961,4.972375690607734) - Current c(0.0,0.0) - Node n5 - Voltage c(4.475138121546961,4.972375690607735) - Current c(0.0,0.0) - -inductor l5: 0.9 Henrys - Node n6 - Voltage c(4.475138121546961,4.972375690607736) - Current c(0.5524861878453039,-0.49723756906077343) - Node n7 - Voltage c(0.0,0.0) - Current c(-0.5524861878453039,0.49723756906077343) - - -yes -| ?- go2. - -COMPONENT CONNECTIONS TO NODE n4 -transistor q1: type bc108 (base, emitter, collector) - Node base - Voltage c(1.9092219020172907,0.0) - Current c(9.005763688760816e-05,0.0) - Node n3 - Voltage c(1.8191642651296822,0.0) - Current c(-0.009095821325648411,0.0) - Node n4 - Voltage c(-0.010742461656573443,0.0) - Current c(0.009005763688760804,0.0) - -resistor r3: 200 Ohms - Node n4 - Voltage c(-0.010742461656573443,0.0) - Current c(-5.3712308282867614e-05,0.0) - Node ground2 - Voltage c(0.0,0.0) - Current c(5.3712308282867614e-05,0.0) - -transformer t2: ratio of 0.2 - Node n4 - Voltage c(-0.010742461656573443,0.0) - Current c(-0.008952051380477936,0.0) - Node ground2 - Voltage c(0.0,0.0) - Current c(0.008952051380477936,0.0) - Node out - Voltage c(-0.05371230828286761,0.0) - Current c(0.001790410276095587,0.0) - Node ground3 - Voltage c(0.0,0.0) - Current c(-0.001790410276095587,0.0) - - -COMPONENT CONNECTIONS TO NODE out -transformer t2: ratio of 0.2 - Node n4 - Voltage c(-0.010742461656573443,0.0) - Current c(-0.008952051380477936,0.0) - Node ground2 - Voltage c(0.0,0.0) - Current c(0.008952051380477936,0.0) - Node out - Voltage c(-0.05371230828286761,0.0) - Current c(0.001790410276095587,0.0) - Node ground3 - Voltage c(0.0,0.0) - Current c(-0.001790410276095587,0.0) - -resistor r5: 30 Ohms - Node out - Voltage c(-0.05371230828286761,0.0) - Current c(-0.001790410276095587,0.0) - Node ground3 - Voltage c(0.0,0.0) - Current c(0.001790410276095587,0.0) - - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/023 b/CLPQR/clpqr/examples/SESSION/023 deleted file mode 100644 index b17e3e229..000000000 --- a/CLPQR/clpqr/examples/SESSION/023 +++ /dev/null @@ -1,51 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/smm')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/smm...} -{Warning: [X] - singleton variables in notmem/2 in lines 61-62} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/smm consulted, 70 msec 8976 bytes} - -yes -| ?- go. -S = 9, E = 8, N = 9, D = 9, M = 1, O = 0, R = 8, Y = 7 -S = 9, E = 8, N = 9, D = 8, M = 1, O = 0, R = 8, Y = 6 -S = 9, E = 8, N = 9, D = 7, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 8, N = 9, D = 6, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 8, N = 9, D = 5, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 8, N = 9, D = 4, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 8, N = 9, D = 3, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 8, N = 9, D = 2, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 7, N = 8, D = 9, M = 1, O = 0, R = 8, Y = 6 -S = 9, E = 7, N = 8, D = 8, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 7, N = 8, D = 7, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 7, N = 8, D = 6, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 7, N = 8, D = 5, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 7, N = 8, D = 4, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 7, N = 8, D = 3, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 6, N = 7, D = 9, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 6, N = 7, D = 8, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 6, N = 7, D = 7, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 6, N = 7, D = 6, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 6, N = 7, D = 5, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 6, N = 7, D = 4, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 5, N = 6, D = 9, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 5, N = 6, D = 8, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 - -Ans: -S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/024 b/CLPQR/clpqr/examples/SESSION/024 deleted file mode 100644 index 03535df51..000000000 --- a/CLPQR/clpqr/examples/SESSION/024 +++ /dev/null @@ -1,33 +0,0 @@ -/tmp/clpr - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/toolpath')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/toolpath...} -{Warning: [T] - singleton variables in lookup/2 in lines 20-22} -{Warning: [H] - singleton variables in lookup/2 in lines 22-24} -{Warning: [A,B,X,Y] - singleton variables in get_vars/2 in lines 42-43} -{Warning: [A,B,C,M] - singleton variables in get_vars/2 in lines 44-45} -{Warning: [Y2] - singleton variables in get_constraint/2 in lines 57-64} -{Warning: [C,M,N] - singleton variables in make_db/3 in lines 79-81} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/toolpath consulted, 130 msec 9904 bytes} - -yes -| ?- go. -G00 X10.000 Y10.000 -G01 X10.000 Y20.000 -G01 X15.000 Y15.000 -G01 X10.000 Y10.000 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/030 b/CLPQR/clpqr/examples/SESSION/030 deleted file mode 100644 index da515d488..000000000 --- a/CLPQR/clpqr/examples/SESSION/030 +++ /dev/null @@ -1,27 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/caneghem')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/caneghem.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/caneghem.pl consulted, 2520 msec 74144 bytes} - -yes -| ?- time(caneghem(10,L)). -%%% Timing 00:00:00.060 0.060 - -L = [1.180361618569526,-0.1898247042801352,-0.030994722136251738,-0.009616196004351119,0.08947578301403712,-0.05816832474193178,0.05131550710891376,-0.048661569893130585,-0.09665282648248967,0.112765434845812] ? - -yes -| ?- time(caneghem(20,L)). -%%% Timing 00:00:00.240 0.240 - -L = [1.1771991533526154,-0.3677642194714706,-0.22059024017411974,0.07214096754607921,-0.04111968920165934,-0.004177226166045676,0.04879867086682026,-0.13423890971551566,0.02001872640660113,0.22953375242084173,-0.10544851408837679,0.12811597449720158,0.16864165436232448,0.06723448901855214,-0.07013899425181176,0.050157028592082514,-0.12728007887627196,0.135793403876429,0.1498397702858789,-0.17671571928015453] ? - -yes -| ?- time(caneghem(50,L)). -%%% Timing 00:00:02.600 2.600 - -L = [2.508741846655168,0.9593654809880335,-0.3292365950578988,-0.06906112306788492,0.048323810270536505,0.6234464234295257,0.5846853367908995,0.1323953951743464,-0.4662055884466053,0.18150850965382204,-0.055933552069652115,0.6875968078160808,-1.196189723326641,-0.33344551191813265,-0.12299286303639723,-0.10478366723139865,-0.06355266206797038,-0.3434680164467263,-0.533938161282979,0.4511468891304816,-0.5823641186858809,0.6574493037432098,0.548047843404309,0.15401834452420127,-0.19926797646772515,-0.5235145627726111,1.1031281203771333,-0.5022272273019587,0.14907899497507549,0.08019445782741186,-0.9014009232330955,0.6013394766470118,-0.37457184037407687,-0.07351165783697981,-0.15808699797945325,0.3020665769523162,0.3492022324403419,-0.2063460453723508,-0.15919364319134321,-0.5248918818200423,0.27589725065363346,-0.5212003750683581,-0.534258112209033,-0.209811998058725,0.08983278566538411,-0.254457055946412,0.2833915592612968,-0.508674809981534,0.14974083758131862,-0.06801159370968507] ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/031 b/CLPQR/clpqr/examples/SESSION/031 deleted file mode 100644 index 34592557c..000000000 --- a/CLPQR/clpqr/examples/SESSION/031 +++ /dev/null @@ -1,32 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/matmul')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/matmul.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/matmul.pl consulted, 50 msec 5216 bytes} - -yes -| ?- inv_hilbert(5). -% took 110 msec -[25.000000000022382,-300.00000000049715,1050.0000000024052,-1400.0000000039422,630.000000002048] -[-300.0000000002686,4800.000000006132,-18900.00000003017,26880.000000050026,-12600.000000026208] -[1050.0000000010832,-18900.000000024073,79380.0000001167,-117600.00000019174,56700.00000009983] -[-1400.0000000012533,26880.000000028263,-117600.00000013839,179200.00000022893,-88200.00000011979] -[630.0000000007072,-12600.000000015554,56700.00000007495,-88200.00000012267,44100.00000006371] - -yes -| ?- inv_hilbert(10). -% took 730 msec -[100.06764055606595,-4955.746750893468,79320.87311277707,-601688.1288004466,2527669.331989608,-6320363.588467166,9632548.1069225,-8773673.357856564,4387341.655298468,-926309.2549045784] -[-4954.583263505397,327088.43938125984,-5888755.171243939,47640829.722639784,-208454422.6267876,536080106.3050636,-833973190.0816677,771622619.5092161,-390658135.1887325,83309806.45795152] -[79282.65010987384,-5887588.611728508,113053989.38333344,-952665276.8719503,4287285196.6575603,-11254751273.977966,17786114554.87667,-16661528858.771124,8520389134.607941,-1832112969.2769487] -[-601278.28283175,47624803.379886195,-952549872.4286704,8255797058.086059,-37926415443.20429,101140061646.08708,-161828052714.71478,153124339918.90198,-78956146207.99248,17096182731.586212] -[2525510.463987293,-208360168.57612622,4286354582.629362,-37922951901.82854,176976129763.71933,-477840819028.144,772275161958.0231,-736819388616.1226,382581917280.6937,-83331832395.71211] -[-6314069.480648408,535789562.6820037,-11251522186.754816,101124429258.4978,-477811689383.5447,1303120253648.7231,-2123600181570.822,2040253943986.3867,-1065667328185.2559,233306407256.48602] -[9621777.540831676,-833457524.1493945,17779983322.230595,-161794800592.89096,772191081502.5444,-2123500324124.862,3484684566848.1865,-3367823701794.478,1768095223156.5308,-388814926368.6053] -[-8762948.703959834,771096470.9348224,-16655008795.382607,153086775081.8679,-736712226467.4573,2040086157995.643,-3367706777384.1885,3271442141044.1406,-1725154609484.48,380858222342.8272] -[4381581.535326206,-390370462.83225214,8516721017.329105,-78934185276.29749,382514968210.1026,-1065549816609.6667,1767985562818.6477,-1725107944970.8896,913278439265.5413,-202321697134.3589] -[-925019.6256684132,83244518.21734402,-1831262894.88349,17090956320.177563,-83315214328.6161,233275346511.60562,-388782247484.8793,380839681227.99866,-202317350053.5215,44958695698.27329] - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/032 b/CLPQR/clpqr/examples/SESSION/032 deleted file mode 100644 index ba3b58596..000000000 --- a/CLPQR/clpqr/examples/SESSION/032 +++ /dev/null @@ -1,86 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/simplex')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/simplex.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/simplex.pl consulted, 230 msec 15360 bytes} - -yes -| ?- time(example(N,V,O)). -%%% Timing 00:00:00.010 0.010 - -N = 1, -O = 17200.0, -V = [40.0,160.0] ? ; -%%% Timing 00:00:00.020 0.020 - -N = 2, -O = 7.0, -V = [1.0,0.0,1.5] ? ; -%%% Timing 00:00:00.020 0.020 - -N = 3, -O = 18850.0, -V = [38.0,170.0] ? ; -%%% Timing 00:00:00.030 0.030 - -N = 4, -O = 310.0, -V = [7.0,2.0] ? ; -%%% Timing 00:00:00.030 0.030 - -N = 5, -O = 5.0, -V = [0.0,0.0,2.5000000000000004] ? ; -%%% Timing 00:00:00.020 0.020 - -N = 6, -O = -7.0, -V = [1.0,0.0,1.5] ? ; -%%% Timing 00:00:00.070 0.070 - -N = 7, -O = -70.0, -V = [3.000000000000003,0.0,0.0,4.0,1.9999999999999998,0.0,5.0] ? ; -%%% Timing 00:00:00.070 0.070 - -N = 8, -O = -19.500000000000007, -V = [0.0,3.4999999999999982,0.0,0.0,0.0,0.5000000000000009,0.0] ? ; -%%% Timing 00:00:00.220 0.220 - -N = 9, -O = 1167185.7255923203, -V = [9.462945942265794,5.194418913398691,13.466605392156858,4.31985294117647,10.36764705882353,0.0,60.0,63.4629459422658,62.311070261437905,69.54656862745097,66.91176470588235,70.58823529411765,0.0,0.0,0.0,0.0,0.0,1411.7647058823532] ? ; -%%% Timing 00:00:00.390 0.390 - -N = utility, -O = 46554.76190476336, -V = [0.0,161.90476190476357,28.571428571428214,142.8571428571422,666.6666666666667,0.0,0.0,0.0,999.9999999999999,0.0,1914.2857142857135,1928.5714285714234,0.0,1985.7142857142862,3999.9999999999973,397.6190476190506,2180.9523809523735,0.0,0.0,1000.0,500.00000000000006,2000.0000000000002,100.0,5000.000000000001,250.0000000000009,600.0,114.28571428571195,0.0] ? ; -%%% Timing 00:00:00.220 0.220 - -N = electricity, -O = 15628.571428582796, -V = [0.0,428.5714285714289,28.57142857142867,_A,_B,0.0,0.0,0.0,_C,_D,_E,_F,_G,_H,1000.0,500.0,2000.0,100.0], -{_A+0.6923076923076922*_G=<235.16483516483487}, -{_G>=0.0}, -{_A>=0.0}, -{_D=185.71428571428618+1.5*_A+0.4999999999999999*_G}, -{_F=1128.571428571429-_G}, -{_H=1985.7142857142853+_G}, -{_C=814.285714285714-1.5*_A-0.4999999999999999*_G}, -{_E=1914.2857142857165-_G}, -{_B=542.8571428571427-_A} ? ; -%%% Timing 00:00:00.300 0.300 - -N = water, -O = 23449.999999986194, -V = [0.0,0.0,0.0,999.9999999944121,5.587935447700301e-09,0.0,49.999999999999545,_A,333.333333337678,_B,3999.999999999989,0.0,2483.333333332131,0.0,0.0,5000.0,250.0,600.0,_C,0.0], -{_C=5.000000000000014*_A}, -{_A>=6.08224581810644e-13}, -{_B=616.666666662262-_A}, -{_A=<22.222222222222626} ? ; -%%% Timing 00:00:00.050 0.050 - -no -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/033 b/CLPQR/clpqr/examples/SESSION/033 deleted file mode 100644 index 2aa23638d..000000000 --- a/CLPQR/clpqr/examples/SESSION/033 +++ /dev/null @@ -1,21 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/squares')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/squares.pl...} -{Warning: [X1,X2,X3,X4,X5,X6,X7,X8,X9] - singleton variables in rectangle/2 in lines 1-40} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/squares.pl consulted, 50 msec 2928 bytes} - -yes -| ?- time(rectangle(A,Rs)). -%%% Timing 00:00:40.060 40.060 - -A = 1.03125, -Rs = [0.46875000000000006,0.5625000000000001,0.24999999999999967,0.21875000000000006,0.1250000000000001,0.4375,0.03124999999999989,0.3124999999999998,0.28124999999999933] ? ; -%%% Timing 00:00:05.020 5.020 - -A = 1.131147540983607, -Rs = [0.5409836065573771,0.5901639344262297,0.45901639344262296,0.08196721311475422,0.032786885245901544,0.14754098360655746,0.409836065573771,0.11475409836065581,0.2622950819672133] ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/034 b/CLPQR/clpqr/examples/SESSION/034 deleted file mode 100644 index 0c51f4139..000000000 --- a/CLPQR/clpqr/examples/SESSION/034 +++ /dev/null @@ -1,52 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/mip')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/mip.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/mip.pl consulted, 2560 msec 97008 bytes} - -yes -| ?- example(1). -incumbent(14.0,[1.0,2.0]) -incumbent(13.0,[2.0,0.9999999999999998]) -1:13.0 -%%% Timing 00:00:00.020 0.020 - -yes -| ?- example(2). -incumbent(-41.999999999999915,[4.440892098500626e-16,1.9999999999999987]) -2: -41.999999999999915 -%%% Timing 00:00:00.010 0.010 - -yes -| ?- example(flugpl). -incumbent(1202699.9999999995,[70.99999999999999,69.99999999999999,70.00000000000001,60.00000000000003,60.00000000000006,0.0,8.000000000000028,7.000000000000014,15.999999999999986,6.0,6.00000000000005]) -incumbent(1202399.9999999995,[72.0,70.00000000000001,70.00000000000001,60.00000000000004,60.00000000000005,0.0,9.000000000000002,7.0,15.999999999999986,6.000000000000007,6.000000000000043]) -incumbent(1202100.0,[73.0,70.00000000000001,70.00000000000001,60.000000000000014,60.000000000000014,0.0,10.0,7.000000000000043,15.999999999999986,6.000000000000007,6.000000000000007]) -incumbent(1201800.0,[74.0,70.0,70.0,60.00000000000007,60.0,0.0,11.000000000000014,6.9999999999999725,15.999999999999986,6.0000000000000036,5.999999999999993]) -incumbent(1201500.0000000005,[75.0,70.00000000000001,70.0,60.00000000000007,60.0,0.0,12.0,6.999999999999986,15.999999999999986,6.0000000000000036,5.999999999999993]) -flugpl:1201500.0000000005 -%%% Timing 00:00:30.150 30.150 - -yes -| ?- example(flugplan). -incumbent(1202700.0000000007,[70.0,7.000000000000007,69.99999999999999,7.999999999999998,71.00000000000013,0.0,5.99999999999999,59.99999999999999,6.000000000000001,60.000000000000014,15.999999999999991]) -incumbent(1202400.0000000007,[70.0,7.0000000000000275,70.0,8.999999999999838,72.0,0.0,6.000000000000004,59.99999999999999,6.0,60.000000000000014,15.999999999999988]) -incumbent(1202099.9999999995,[70.0,6.999999999999851,69.99999999999983,10.0,73.0,0.0,6.000000000000004,59.99999999999999,6.0,60.000000000000014,15.999999999999988]) -incumbent(1201799.9999999993,[70.0,6.999999999999854,69.99999999999989,11.000000000000089,74.0,0.0,6.000000000000002,60.000000000000014,6.0,60.00000000000002,15.999999999999986]) -incumbent(1201499.9999999993,[70.0,6.999999999999854,69.99999999999991,12.000000000000004,75.0,0.0,6.000000000000002,60.000000000000014,6.0,60.00000000000002,15.999999999999986]) -flugplan:1201499.9999999993 -%%% Timing 00:00:11.800 11.800 - -yes -| ?- example(sample2). -incumbent(450.0000000000001,[0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.9999999999999998,0.0,0.0,0.9999999999999997,0.0,1.0,-6.661338147750939e-16]) -incumbent(430.00000000000006,[0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.9999999999999997,1.0000000000000004,0.0,0.0,0.0,1.0,-6.661338147750939e-16]) -incumbent(400.0000000000001,[0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0000000000000002,0.0,0.0,1.0,-6.661338147750939e-16]) -incumbent(385.0000000000001,[0.0,0.0,1.0,0.0,0.0,0.0,1.0000000000000002,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.9999999999999998,0.0,1.0,-6.661338147750939e-16]) -incumbent(375.0000000000001,[0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.1102230246251585e-16,0.0,0.0,0.0,1.0,0.0,-6.661338147750939e-16]) -sample2:375.0000000000001 -%%% Timing 00:00:41.730 41.730 - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/035 b/CLPQR/clpqr/examples/SESSION/035 deleted file mode 100644 index 31efe0b6e..000000000 --- a/CLPQR/clpqr/examples/SESSION/035 +++ /dev/null @@ -1,256 +0,0 @@ -/tmp/clpr - -yes -| ?- [library('clpqr/examples/eliminat')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/eliminat.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/eliminat.pl consulted, 170 msec 15600 bytes} - -yes -| ?- hull([X,Y]). - -{Y=<2.0}, -{X+0.5*Y=<3.0}, -{X>=1.0}, -{Y>= -0.0}, -{X+Y>=2.0} ? - -yes -| ?- example(1,[_,_,X3,X4]). - -{X3-0.3333333333333328*X4>= -0.33333333333333365}, -{X3-1.2222222222222185*X4=<0.1111111111111095}, -{X3-0.8888888888888873*X4=<0.11111111111110945}, -{X3-0.7222222222222214*X4>= -0.2222222222222217}, -{X3-0.16666666666667848*X4=<0.33333333333332205} ? - -yes -| ?- example(2,[X0,X1|_]). - -{X0+0.1467030889468301*X1>= -0.047670549229302576}, -{X0+0.3879120532395401*X1=< -0.7691743524189323}, -{X0+0.01576973710784565*X1>=1.967054191675273}, -{X0-0.31633069046036744*X1>=5.333044707442825}, -{X0+0.14129088466591355*X1>=0.46689259039239467} ? - -yes -| ?- proj(1). -%%% Timing 00:00:00.060 0.060 -[A,B,C,D]:6 -{B>=0.0} -{A>=0.0} -{D-2.999999999999997*C+B+11.999999999999977*A=<0.9999999999999978} -{D-1.2857142857142863*C+0.142857142857143*B+2.5714285714285734*A>=0.142857142857143} -{D-1.6363636363636367*C+0.18181818181818196*B+3.2727272727272747*A>=0.18181818181818196} -{D-1.3846153846153857*C+0.30769230769230776*B+3.4615384615384635*A=<0.30769230769230776} - -%%% Timing 00:00:00.170 0.170 -[A,B,C]:6 -{A>=0.0} -{C-6.000000000000002*B-2.000000000000002*A>= -2.000000000000002} -{C-1.3846153846153848*B+0.30769230769230765*A=<0.30769230769230765} -{C-0.818181818181818*B-0.09090909090909093*A>= -0.09090909090909093} -{C-1.1249999999999998*B-0.12500000000000003*A>= -0.12500000000000003} -{C-2.999999999999995*B+A=<0.999999999999998} - -%%% Timing 00:00:00.160 0.160 -[A,B]:5 -{B-2.9999999999999996*A=<0.9999999999999988} -{B-0.8181818181818189*A>= -0.09090909090909098} -{B-1.1250000000000009*A>= -0.1250000000000004} -{B-1.384615384615386*A=<0.3076923076923073} -{B-6.000000000000392*A>= -2.0000000000001537} - -%%% Timing 00:00:00.160 0.160 -[A]:2 -{A=<1.0000000000000016} -{A>= -0.4999999999999999} - -%%% Timing 00:00:00.040 0.040 -[]:0 - -%%% Timing 00:00:00.150 0.150 -[A]:2 -{A=<0.5000000000000004} -{A>= -0.5} - -%%% Timing 00:00:00.150 0.150 -[A,B]:3 -{A>=0.0} -{B-0.49999999999999994*A>= -0.49999999999999994} -{B+A=<1.0000000000000056} - -%%% Timing 00:00:00.120 0.120 -[A]:2 -{A>=0.0} -{A=<1.0} - -%%% Timing 00:00:00.150 0.150 -[A,B]:3 -{A>=0.0} -{B-0.4999999999999997*A>= -0.49999999999999983} -{B+0.5000000000000008*A=<0.5000000000000007} - -%%% Timing 00:00:00.140 0.140 -[A,B,C]:6 -{A>=0.0} -{C-1.9999999999999998*B+2.999999999999999*A>= -0.0} -{C-1.384615384615385*B+3.461538461538463*A=<0.3076923076923077} -{C-B+A>= -0.0} -{C-1.3333333333333335*B+1.3333333333333341*A>= -0.0} -{C-2.999999999999997*B+11.999999999999982*A=<0.9999999999999984} - -%%% Timing 00:00:00.140 0.140 -[A,B]:4 -{A>=0.0} -{B-7.199999999999999*A>= -0.7999999999999998} -{B-4.499999999999999*A>= -0.4999999999999999} -{B+4.500000000000004*A=<1.0000000000000007} - -%%% Timing 00:00:00.110 0.110 -[A]:2 -{A>=0.0} -{A=<0.1538461538461539} - -%%% Timing 00:00:00.130 0.130 -[A,B]:4 -{A>=0.0} -{B-6.400000000000002*A>= -0.6000000000000002} -{B-5.500000000000002*A>= -0.5000000000000001} -{B+0.7500000000000011*A=<0.5000000000000001} - -%%% Timing 00:00:00.130 0.130 -[A,B,C]:5 -{B>=0.0} -{A>=0.0} -{C+B+4.500000000000005*A=<1.0000000000000013} -{C-0.49999999999999994*B-4.5*A>= -0.49999999999999994} -{C-0.7999999999999999*B-7.2*A>= -0.7999999999999999} - -%%% Timing 00:00:00.100 0.100 -[A,B]:3 -{B>= -1.1102230246251568e-16} -{A>=0.0} -{B+6.499999999999998*A=<1.0} - -%%% Timing 00:00:00.130 0.130 -[A,B,C]:5 -{B>=0.0} -{A>=0.0} -{C+0.49999999999999806*B+0.7499999999999849*A=<0.49999999999999806} -{C-0.5*B-5.499999999999998*A>= -0.5} -{C-0.5999999999999998*B-6.399999999999999*A>= -0.5999999999999998} - -%%% Timing 00:00:00.020 0.020 - -no -| ?- proj(3). -%%% Timing 00:00:00.060 0.060 -[A,B,C,D]:6 -{B>=0.0} -{A>0.0} -{D-2.999999999999997*C+B+11.999999999999977*A=<0.9999999999999978} -{D-1.2857142857142863*C+0.142857142857143*B+2.5714285714285734*A>=0.142857142857143} -{D-1.6363636363636367*C+0.18181818181818196*B+3.2727272727272747*A>=0.18181818181818196} -{D-1.3846153846153857*C+0.30769230769230776*B+3.4615384615384635*A=<0.30769230769230776} - -%%% Timing 00:00:00.160 0.160 -[A,B,C]:6 -{A>=0.0} -{C-6.000000000000002*B-2.000000000000002*A>= -2.000000000000002} -{C-1.3846153846153848*B+0.30769230769230765*A<0.30769230769230765} -{C-0.818181818181818*B-0.09090909090909093*A>= -0.09090909090909093} -{C-1.1249999999999998*B-0.12500000000000003*A>= -0.12500000000000003} -{C-2.999999999999995*B+A<0.999999999999998} - -%%% Timing 00:00:00.170 0.170 -[A,B]:5 -{B-2.9999999999999996*A<0.9999999999999988} -{B-0.8181818181818189*A>= -0.09090909090909098} -{B-1.1250000000000009*A>= -0.1250000000000004} -{B-1.384615384615386*A<0.3076923076923073} -{B-6.000000000000392*A>= -2.0000000000001537} - -%%% Timing 00:00:00.180 0.180 -[A]:2 -{A<1.0000000000000016} -{A> -0.4999999999999999} - -%%% Timing 00:00:00.030 0.030 -[]:0 - -%%% Timing 00:00:00.150 0.150 -[A]:2 -{A<0.5000000000000004} -{A> -0.5} - -%%% Timing 00:00:00.140 0.140 -[A,B]:3 -{A>=0.0} -{B-0.49999999999999994*A> -0.49999999999999994} -{B+A<1.0000000000000056} - -%%% Timing 00:00:00.130 0.130 -[A]:2 -{A>=0.0} -{A<1.0} - -%%% Timing 00:00:00.140 0.140 -[A,B]:3 -{A>=0.0} -{B-0.4999999999999997*A> -0.49999999999999983} -{B+0.5000000000000008*A<0.5000000000000007} - -%%% Timing 00:00:00.120 0.120 -[A,B,C]:6 -{A>0.0} -{C-1.9999999999999998*B+2.999999999999999*A>= -0.0} -{C-1.384615384615385*B+3.461538461538463*A=<0.3076923076923077} -{C-B+A>= -0.0} -{C-1.3333333333333335*B+1.3333333333333341*A>= -0.0} -{C-2.999999999999997*B+11.999999999999982*A=<0.9999999999999984} - -%%% Timing 00:00:00.140 0.140 -[A,B]:4 -{A>0.0} -{B-7.199999999999999*A>= -0.7999999999999998} -{B-4.499999999999999*A>= -0.4999999999999999} -{B+4.500000000000004*A=<1.0000000000000007} - -%%% Timing 00:00:00.120 0.120 -[A]:2 -{A>0.0} -{A=<0.1538461538461539} - -%%% Timing 00:00:00.120 0.120 -[A,B]:4 -{A>0.0} -{B-6.400000000000002*A>= -0.6000000000000002} -{B-5.500000000000002*A>= -0.5000000000000001} -{B+0.7500000000000011*A=<0.5000000000000001} - -%%% Timing 00:00:00.110 0.110 -[A,B,C]:5 -{B>=0.0} -{A>0.0} -{C+B+4.500000000000005*A=<1.0000000000000013} -{C-0.49999999999999994*B-4.5*A>= -0.49999999999999994} -{C-0.7999999999999999*B-7.2*A>= -0.7999999999999999} - -%%% Timing 00:00:00.130 0.130 -[A,B]:3 -{B>= -1.1102230246251568e-16} -{A>0.0} -{B+6.499999999999998*A=<1.0} - -%%% Timing 00:00:00.110 0.110 -[A,B,C]:5 -{B>=0.0} -{A>0.0} -{C+0.49999999999999806*B+0.7499999999999849*A=<0.49999999999999806} -{C-0.5*B-5.499999999999998*A>= -0.5} -{C-0.5999999999999998*B-6.399999999999999*A>= -0.5999999999999998} - -%%% Timing 00:00:00.020 0.020 - -no -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/110 b/CLPQR/clpqr/examples/SESSION/110 deleted file mode 100644 index 1d4b1c590..000000000 --- a/CLPQR/clpqr/examples/SESSION/110 +++ /dev/null @@ -1,66 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 50 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 130 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/air')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/air...} -{Warning: [T] - singleton variables in comp/3 in lines 27-28} -{Warning: [X] - singleton variables in zero/1 in lines 38-40} -{Warning: [T] - singleton variables in bal_side/3 in lines 45-50} -{Warning: [X] - singleton variables in add_species/4 in lines 56-57} -{Warning: [NUM] - singleton variables in add_elements/5 in lines 57-60} -{Warning: [PROP,X] - singleton variables in add_elements/5 in lines 68-70} -{Warning: [F1] - singleton variables in go/0 in lines 76-87} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/air consulted, 130 msec 10384 bytes} - -yes -| ?- go. -species air -molecule n2 -molecule o2 -atom o -species fuel -molecule c -atom c -species flue -molecule co2 -atom c -atom o -molecule co -atom c -atom o -molecule o2 -atom o -molecule n2 -With base of 1.000000 mol of fuel -air (just to burn the carbon) = 5.317460 mol -flue (mol) :6.666667 - -species air -molecule n2 -molecule o2 -atom o -species fuel -molecule c -atom c -species full_comb -molecule co2 -atom c -atom o -molecule n2 -Compared with theoretical air (for complete combustion): - 4.761905 mol -Excess = 11.666667% - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/111 b/CLPQR/clpqr/examples/SESSION/111 deleted file mode 100644 index f9f2b005f..000000000 --- a/CLPQR/clpqr/examples/SESSION/111 +++ /dev/null @@ -1,64 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 50 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/amplif')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/amplif...} -{Warning: [Collector_Currents] - singleton variables in dc_analysis/3 in lines 1-31} -{Warning: [Type,Vc] - singleton variables in component_ss/6 in lines 70-75} -{Warning: [V1,V2] - singleton variables in component_dc/7 in lines 89-90} -{Warning: [Vbreak,Vreak] - singleton variables in component_dc/7 in lines 93-96} -{Warning: [Vbreak] - singleton variables in diode_state/5 in lines 96-104} -{Warning: [Beta] - singleton variables in transistor_state/7 in lines 122-127} -{Warning: [Beta] - singleton variables in transistor_state/7 in lines 127-133} -{Warning: [Beta,Vc,Vcesat] - singleton variables in transistor_state/7 in lines 133-139} -{Warning: [Beta,Vc,Vcesat] - singleton variables in transistor_state/7 in lines 139-144} -{Warning: [Points] - singleton variables in print_circuit/1 in lines 202-205} -{Warning: [R1,R2,Rc,Re] - singleton variables in circuit/6 in lines 233-244} -{Warning: [C1,C2,C3,R1,R2,Rc,Re] - singleton variables in circuit/6 in lines 244-255} -{Warning: [C1,C3,R1,R2,Re] - singleton variables in circuit/6 in lines 255-264} -{Warning: [St1,St2,St3,St4,State] - singleton variables in go1/0 in lines 264-274} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/amplif consulted, 410 msec 22640 bytes} - -yes -| ?- go1. -cc1 at 15 [0,18/125,0,-18/125] -cc2 at -12 [-57/500,57/500] -gnd at 0 [0,-3/100,3/100] -a at 3/5 [57/500,-18/125,0,3/100] -p1 at 0 [57/500,-57/500] -b at -3/5 [0,57/500,-57/500] -c at 15 [0,0] - diode at d1 [di1,forward] - diode at d2 [di1,reverse] - resistor at r1 100 - diode at d3 [di1,forward] - diode at d4 [di1,forward] - resistor at r2 100 - transistor at tr [npn,tr0,cutoff] - resistor at rc 100 - -yes -| ?- go2. -Stab 407/209090 -Outresist 47500/55419 - capacitor at c1 _1412 - resistor at r1 100 - resistor at r2 100 - transistor at tr [npn,tr0,active] - resistor at re 100 - capacitor at c3 _1334 -[[capacitor,c1,_1412,[in,b]],[resistor,r1,rat(100,1),[b,cc1]],[resistor,r2,rat(100,1),[b,gnd]],[transistor,tr,[npn,tr0,active],[b,cc1,e]],[resistor,re,rat(100,1),[e,gnd]],[capacitor,c3,_1334,[e,out]]] - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/112 b/CLPQR/clpqr/examples/SESSION/112 deleted file mode 100644 index a3c72b64f..000000000 --- a/CLPQR/clpqr/examples/SESSION/112 +++ /dev/null @@ -1,27 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/complex')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/complex...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/complex consulted, 20 msec 3808 bytes} - -yes -| ?- go. - -[32,88,32,61,32]c(rat(1,1),rat(1,1)) -[32,89,32,61,32]c(rat(2,1),rat(2,1)) -[32,90,32,61,32]c(rat(0,1),rat(4,1)) - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/113 b/CLPQR/clpqr/examples/SESSION/113 deleted file mode 100644 index bec084236..000000000 --- a/CLPQR/clpqr/examples/SESSION/113 +++ /dev/null @@ -1,138 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/critical')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/critical...} -{Warning: [End] - singleton variables in cpm/2 in lines 62-67} -{Warning: [Es,From,Lc,T] - singleton variables in buildv/3 in lines 81-83} -{Warning: [H] - singleton variables in buildv/3 in lines 83-85} -{Warning: [Es,Lc,T,To] - singleton variables in buildv/3 in lines 85-87} -{Warning: [H] - singleton variables in buildv/3 in lines 87-89} -{Warning: [H] - singleton variables in addedg/3 in lines 91-93} -{Warning: [T] - singleton variables in addedg/3 in lines 93-94} -{Warning: [H] - singleton variables in addedg/3 in lines 94-96} -{Warning: [I] - singleton variables in early_late/4 in lines 102-106} -{Warning: [I] - singleton variables in early_late/3 in lines 108-112} -{Warning: [End] - singleton variables in setearly/5 in lines 118-121} -{Warning: [Last] - singleton variables in setlate/4 in lines 128-131} -{Warning: [T] - singleton variables in getnode/4 in lines 136-139} -{Warning: [H] - singleton variables in getnode/4 in lines 139-141} -{Warning: [G] - singleton variables in analyse/2 in lines 141-148} -{Warning: [I] - singleton variables in analyse/2 in lines 148-151} -{Warning: [Lci] - singleton variables in compute/9 in lines 157-166} -{Warning: [From] - singleton variables in print_node/1 in lines 176-180} -{Warning: [From] - singleton variables in print_node/1 in lines 186-191} - ->>> Sample goals: go1/0, go2/0, go3/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/critical consulted, 210 msec 18416 bytes} - -yes -| ?- go1. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 3 2 3 2 0 -n1 n3 2 0 2 0 0 * --------------------------------------------------- - n2 3 5 --------------------------------------------------- -n2 n4 2 5 5 2 2 --------------------------------------------------- - n3 2 2 --------------------------------------------------- -n3 n4 5 2 7 0 0 * --------------------------------------------------- -END NODE n4 7 7 - -yes -| ?- go2. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- - n5 8 8 --------------------------------------------------- -n5 n6 9 8 17 0 0 * -n5 n7 5 12 13 4 4 --------------------------------------------------- - n6 17 17 --------------------------------------------------- -n6 n7 0 17 17 0 0 * -n6 n8 4 19 21 2 2 --------------------------------------------------- - n7 17 17 --------------------------------------------------- -n7 n8 6 17 23 0 0 * --------------------------------------------------- - n4 3 8 --------------------------------------------------- -n4 n7 4 13 7 10 10 -n4 n5 0 8 3 5 5 -n4 n8 3 20 6 17 17 --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 2 4 2 4 0 -n1 n3 6 0 6 0 0 * -n1 n4 3 5 3 5 0 --------------------------------------------------- - n2 2 6 --------------------------------------------------- -n2 n3 0 6 2 4 4 -n2 n5 1 7 3 5 5 -n2 n6 4 13 6 11 11 --------------------------------------------------- - n3 6 6 --------------------------------------------------- -n3 n5 2 6 8 0 0 * --------------------------------------------------- -END NODE n8 23 23 - -yes -| ?- go3. - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 4 0 4 0 0 * -n1 n3 3 4 3 4 2 -n1 n4 4 6 4 6 0 --------------------------------------------------- - n2 4 4 --------------------------------------------------- -n2 n5 7 4 11 0 0 * -n2 n3 1 6 5 2 0 -n2 n7 8 8 12 4 4 --------------------------------------------------- - n3 5 7 --------------------------------------------------- -n3 n5 4 7 9 2 2 --------------------------------------------------- - n4 4 10 --------------------------------------------------- -n4 n6 2 10 6 6 6 --------------------------------------------------- - n5 11 11 --------------------------------------------------- -n5 n6 1 11 12 0 0 * -n5 n7 3 13 14 2 2 --------------------------------------------------- -END NODE n7 16 16 --------------------------------------------------- - n6 12 12 --------------------------------------------------- -n6 n7 4 12 16 0 0 * - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/114 b/CLPQR/clpqr/examples/SESSION/114 deleted file mode 100644 index cea3b63ca..000000000 --- a/CLPQR/clpqr/examples/SESSION/114 +++ /dev/null @@ -1,25 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/fib')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/fib...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/fib consulted, 20 msec 3712 bytes} - -yes -| ?- go. -forward: fib(10) = 89 -backward: fib(10) = 89 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/115 b/CLPQR/clpqr/examples/SESSION/115 deleted file mode 100644 index 04a922d6f..000000000 --- a/CLPQR/clpqr/examples/SESSION/115 +++ /dev/null @@ -1,29 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/findroot')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/findroot...} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/findroot consulted, 30 msec 4528 bytes} - -yes -| ?- go. -1.70000000 -0.44834437 -0.91953538 -0.99701354 -0.99999555 -1.00000000 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/116 b/CLPQR/clpqr/examples/SESSION/116 deleted file mode 100644 index b7e308639..000000000 --- a/CLPQR/clpqr/examples/SESSION/116 +++ /dev/null @@ -1,35 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/invert')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/invert...} -{Warning: [C] - singleton variables in allvec/2 in lines 21-23} -{Warning: [H] - singleton variables in mylength/2 in lines 27-28} -{Warning: [H] - singleton variables in mylength/2 in lines 28-31} -{Warning: [A] - singleton variables in rowtocol/2 in lines 50-51} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/invert consulted, 90 msec 8288 bytes} - -yes -| ?- go. - NR = - 0.2917 0.0417 -0.2083 - -0.0833 0.4167 -0.0833 - 0.0417 -0.3750 0.2083 - T = - 1.0000 0.0000 0.0000 - 0.0000 1.0000 0.0000 - 0.0000 0.0000 1.0000 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/117 b/CLPQR/clpqr/examples/SESSION/117 deleted file mode 100644 index 0c850dbc3..000000000 --- a/CLPQR/clpqr/examples/SESSION/117 +++ /dev/null @@ -1,53 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 110 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/laplace')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/laplace...} -{Warning: [BL,TL] - singleton variables in laplace_vec/3 in lines 24-28} -{Warning: [B11,B12,B13,B14,B21,B24,B31,B34,B42,B43,M22,M23,M32,M33] - singleton variables in go2/0 in lines 58-81} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/laplace consulted, 80 msec 7408 bytes} - -yes -| ?- go1. - - 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 - 100.00 51.11 32.52 24.56 21.11 20.12 21.11 24.56 32.52 51.11 100.00 - 100.00 71.91 54.41 44.63 39.74 38.26 39.74 44.63 54.41 71.91 100.00 - 100.00 82.12 68.59 59.80 54.97 53.44 54.97 59.80 68.59 82.12 100.00 - 100.00 87.97 78.03 71.00 66.90 65.56 66.90 71.00 78.03 87.97 100.00 - 100.00 91.71 84.58 79.28 76.07 75.00 76.07 79.28 84.58 91.71 100.00 - 100.00 94.30 89.29 85.47 83.10 82.30 83.10 85.47 89.29 94.30 100.00 - 100.00 96.20 92.82 90.20 88.56 88.00 88.56 90.20 92.82 96.20 100.00 - 100.00 97.67 95.59 93.96 92.93 92.58 92.93 93.96 95.59 97.67 100.00 - 100.00 98.89 97.90 97.12 96.63 96.46 96.63 97.12 97.90 98.89 100.00 - 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 - -yes -| ?- go2. - -yes -| ?- laplace([ - [B11, B12, B13, B14], - [B21, M22, M23, B24], - [B31, M32, M33, B34], - [B44, B42, B43, B44] - ]). - -{M32= -(B12)-B21+4*M22-M23}, -{M33= -(M22)+4*M23-B13-B24}, -{B42=-4*B12-4*B21+16*M22-8*M23+B13+B24-B31}, -{B43=B12+B21-8*M22+16*M23-4*B13-4*B24-B34} ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/118 b/CLPQR/clpqr/examples/SESSION/118 deleted file mode 100644 index 0ec3ebcb1..000000000 --- a/CLPQR/clpqr/examples/SESSION/118 +++ /dev/null @@ -1,46 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 90 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/mortgage')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/mortgage...} -{Warning: [Int] - singleton variables in go4/0 in lines 45-51} - ->>> Sample goals: go1/0, go2/0, go3/0, go4/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/mortgage consulted, 20 msec 4992 bytes} - -yes -| ?- go1. -Forward: MP = 1721.65 -Backward: P = 120000 - -yes -| ?- go2. - -yes -| ?- mg(P,120,0.01,0,MP), dump([P,MP]). - -{P=230038689457366504787696421844051916348685607672853885051027633046922230334437656640810235469538098584320203208140788877352356725532780953940525919735874426790409432648433950808597819868060753380384018578968864514756271928149406197791141200100/3300386894573665047876964218440519163486856076728538850510276330469222303344376566408102354695380985843202032081407888773523567255327809539405259197358744267904094326484339508085978198680607533803840185789688645147562719281494061977911412001*MP} ? - -yes -| ?- mg(P,120,0.01,B,MP), dump([P,B,MP]). - -{P=1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000/3300386894573665047876964218440519163486856076728538850510276330469222303344376566408102354695380985843202032081407888773523567255327809539405259197358744267904094326484339508085978198680607533803840185789688645147562719281494061977911412001*B+230038689457366504787696421844051916348685607672853885051027633046922230334437656640810235469538098584320203208140788877352356725532780953940525919735874426790409432648433950808597819868060753380384018578968864514756271928149406197791141200100/3300386894573665047876964218440519163486856076728538850510276330469222303344376566408102354695380985843202032081407888773523567255327809539405259197358744267904094326484339508085978198680607533803840185789688645147562719281494061977911412001*MP} ? - -yes -| ?- mg(999, 3, Int, 0, 400), dump. - -nonlin:{_B-_B*Int+_A+400=0}, -nonlin:{_A-_A*Int+400=0}, -{_B=599+999*Int} ? - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/119 b/CLPQR/clpqr/examples/SESSION/119 deleted file mode 100644 index 171d5eaf6..000000000 --- a/CLPQR/clpqr/examples/SESSION/119 +++ /dev/null @@ -1,76 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 90 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/option')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/option...} -{Warning: [B,C,P,X] - singleton variables in table/13 in lines 47-54} -{Warning: [B,P,S] - singleton variables in table/13 in lines 54-55} -{Warning: [B,C,S] - singleton variables in table/13 in lines 55-56} -{Warning: [C,P,S,X] - singleton variables in table/13 in lines 56-57} - ->>> Sample goals (some with multiple answers): - go1(W), go2(S, W), go3(S, W), go4(S, W), go5(S, W) -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/option consulted, 130 msec 10032 bytes} - -yes -| ?- go1(W). - -W = -19/4 ? ; - -no -| ?- go2(S,W). - -W = 21/4, -{S>=0}, -{S<50} ? ; - -{W>5}, -{S=221/4-W}, -{W=<21/4} ? ; - -no -| ?- go3(S,W). - -{W>=10}, -{S=187/5-W}, -{W=<187/5} ? ; - -{W>=10}, -{S=313/5+W} ? ; - -no -| ?- go4(S,W). - -W = 57/10, -{S>=0}, -{S<20} ? ; - -{S>=20}, -{S<40}, -{W=257/10-S} ? ; - -W = -143/10, -{S>=40}, -{S<60} ? ; - -{S>=60}, -{S<80}, -{W=-743/10+S} ? ; - -W = 57/10, -{S>=80} ? ; - -no -| ?- go5(S,W). - -no -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/120 b/CLPQR/clpqr/examples/SESSION/120 deleted file mode 100644 index 454ebf585..000000000 --- a/CLPQR/clpqr/examples/SESSION/120 +++ /dev/null @@ -1,64 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 130 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/pictures')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/pictures...} -{Warning: [DotDashInvis,Text] - singleton variables in box/3 in lines 66-73} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/pictures consulted, 110 msec 12768 bytes} - -yes -| ?- go1. -.PS 2i -line from 3.2,1.8 to 0.688979,1.17224 -line from 0.688979,1.17224 to 2.30239,4.19362 -line from 2.30239,4.19362 to 3.2,1.8 -line from 0,1 to 4,2 dashed -line from 3.5,1 to 2,5 dashed -line from 0.33,0.5 to 3,5.5 dashed - " c1 " at 0,1 rjust - " c2 " at 3.5,1 rjust - " c3 " at 0.33,0.5 rjust -.PE - -yes -| ?- go2. -.PS 3i -line from 0,0 to 8,10 -line from 8,10 to 10,10 -line from 10,10 to 10,1 -line from 10,1 to 0,0 -line from 4,5 to 9,10 dashed -line from 9,10 to 10,5.5 dashed -line from 10,5.5 to 5,0.5 dashed -line from 5,0.5 to 4,5 dashed -line from 0,20 to 0,15 -line from 0,15 to 10,15 -line from 10,15 to 10,20 -line from 10,20 to 0,20 -line from 0,17.5 to 5,15 dashed -line from 5,15 to 10,17.5 dashed -line from 10,17.5 to 5,20 dashed -line from 5,20 to 0,17.5 dashed -line from 5,30 to 10,23 -line from 10,23 to 15,30 -line from 15,30 to 10,25 -line from 10,25 to 5,30 -line from 7.5,26.5 to 12.5,26.5 dashed -line from 12.5,26.5 to 12.5,27.5 dashed -line from 12.5,27.5 to 7.5,27.5 dashed -line from 7.5,27.5 to 7.5,26.5 dashed -.PE - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/122 b/CLPQR/clpqr/examples/SESSION/122 deleted file mode 100644 index 335650bbb..000000000 --- a/CLPQR/clpqr/examples/SESSION/122 +++ /dev/null @@ -1,160 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 30 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 30 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 100 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/rlc')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rlc...} -{Warning: [Comp,Num,X] - singleton variables in get_node_vars/2 in lines 22-26} -{Warning: [V] - singleton variables in insert/3 in lines 36-37} -{Warning: [W] - singleton variables in solve/5 in lines 43-47} -{Warning: [N,V] - singleton variables in zero_currents/1 in lines 47-52} -{Warning: [Vs] - singleton variables in ground_nodes/2 in lines 69-70} -{Warning: [I,Vs] - singleton variables in ground_node/2 in lines 70-71} -{Warning: [I,N1,V] - singleton variables in ground_node/2 in lines 71-72} -{Warning: [W] - singleton variables in iv_reln/5 in lines 85-89} -{Warning: [I,W] - singleton variables in iv_reln/5 in lines 89-89} -{Warning: [V,W] - singleton variables in iv_reln/5 in lines 89-90} -{Warning: [I,L,W] - singleton variables in iv_reln/5 in lines 95-96} -{Warning: [L,V,W] - singleton variables in iv_reln/5 in lines 96-97} -{Warning: [W] - singleton variables in iv_reln/5 in lines 97-98} -{Warning: [I4,NV4,W] - singleton variables in addcomp/5 in lines 111-127} -{Warning: [W] - singleton variables in addcomp/5 in lines 129-145} -{Warning: [L2,X,Y] - singleton variables in subst/4 in lines 150-152} -{Warning: [Im] - singleton variables in c_real/2 in lines 169-171} -{Warning: [Re] - singleton variables in c_imag/2 in lines 171-173} -{Warning: [Ls] - singleton variables in selective_print/2 in lines 190-191} -{Warning: [Comp,Nodes,Num,X] - singleton variables in print_nodes/3 in lines 198-200} -{Warning: [Heading_flag,N1] - singleton variables in print_nodes/3 in lines 200-201} -{Warning: [Comp,Nodes,Num,X] - singleton variables in print_comps/2 in lines 205-207} -{Warning: [Num] - singleton variables in print_comps/2 in lines 207-208} -{Warning: [N,X] - singleton variables in heading/2 in lines 212-213} -{Warning: [I,Ls,V] - singleton variables in member/2 in lines 213-215} -{Warning: [I,N2,V] - singleton variables in member/2 in lines 215-217} -{Warning: [R3,W] - singleton variables in go2/0 in lines 285-359} - ->>> Sample goals: go1/0, go2/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/rlc consulted, 380 msec 26416 bytes} - -yes -| ?- go1. -resistor r1: 10 Ohms - Node n1 - Voltage c(10,0) - Current c(100/181,-90/181) - Node n2 - Voltage c(810/181,900/181) - Current c(-100/181,90/181) - -resistor r3: 10 Ohms - Node n1 - Voltage c(10,0) - Current c(100/181,-90/181) - Node n4 - Voltage c(810/181,900/181) - Current c(-100/181,90/181) - -inductor l1: 9/10 Henrys - Node n2 - Voltage c(810/181,900/181) - Current c(100/181,-90/181) - Node n7 - Voltage c(0,0) - Current c(-100/181,90/181) - -inductor l3: 9/10 Henrys - Node n4 - Voltage c(810/181,900/181) - Current c(100/181,-90/181) - Node n7 - Voltage c(0,0) - Current c(-100/181,90/181) - -capacitor c8: 7/1000 Farads - Node n4 - Voltage c(810/181,900/181) - Current c(0,0) - Node n5 - Voltage c(810/181,900/181) - Current c(0,0) - -inductor l5: 9/10 Henrys - Node n6 - Voltage c(810/181,900/181) - Current c(100/181,-90/181) - Node n7 - Voltage c(0,0) - Current c(-100/181,90/181) - - -yes -| ?- go2. - -COMPONENT CONNECTIONS TO NODE n4 -transistor q1: type bc108 (base, emitter, collector) - Node base - Voltage c(1325/694,0) - Current c(1/11104,0) - Node n3 - Voltage c(2525/1388,0) - Current c(-101/11104,0) - Node n4 - Voltage c(-1875/174541,0) - Current c(25/2776,0) - -resistor r3: 200 Ohms - Node n4 - Voltage c(-1875/174541,0) - Current c(-75/1396328,0) - Node ground2 - Voltage c(0,0) - Current c(75/1396328,0) - -transformer t2: ratio of 1/5 - Node n4 - Voltage c(-1875/174541,0) - Current c(-3125/349082,0) - Node ground2 - Voltage c(0,0) - Current c(3125/349082,0) - Node out - Voltage c(-9375/174541,0) - Current c(625/349082,0) - Node ground3 - Voltage c(0,0) - Current c(-625/349082,0) - - -COMPONENT CONNECTIONS TO NODE out -transformer t2: ratio of 1/5 - Node n4 - Voltage c(-1875/174541,0) - Current c(-3125/349082,0) - Node ground2 - Voltage c(0,0) - Current c(3125/349082,0) - Node out - Voltage c(-9375/174541,0) - Current c(625/349082,0) - Node ground3 - Voltage c(0,0) - Current c(-625/349082,0) - -resistor r5: 30 Ohms - Node out - Voltage c(-9375/174541,0) - Current c(-625/349082,0) - Node ground3 - Voltage c(0,0) - Current c(625/349082,0) - - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/123 b/CLPQR/clpqr/examples/SESSION/123 deleted file mode 100644 index f88711f5e..000000000 --- a/CLPQR/clpqr/examples/SESSION/123 +++ /dev/null @@ -1,51 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 120 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/smm')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/smm...} -{Warning: [X] - singleton variables in notmem/2 in lines 61-62} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/smm consulted, 70 msec 8976 bytes} - -yes -| ?- go. -S = 9, E = 8, N = 9, D = 9, M = 1, O = 0, R = 8, Y = 7 -S = 9, E = 8, N = 9, D = 8, M = 1, O = 0, R = 8, Y = 6 -S = 9, E = 8, N = 9, D = 7, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 8, N = 9, D = 6, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 8, N = 9, D = 5, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 8, N = 9, D = 4, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 8, N = 9, D = 3, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 8, N = 9, D = 2, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 7, N = 8, D = 9, M = 1, O = 0, R = 8, Y = 6 -S = 9, E = 7, N = 8, D = 8, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 7, N = 8, D = 7, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 7, N = 8, D = 6, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 7, N = 8, D = 5, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 7, N = 8, D = 4, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 7, N = 8, D = 3, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 6, N = 7, D = 9, M = 1, O = 0, R = 8, Y = 5 -S = 9, E = 6, N = 7, D = 8, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 6, N = 7, D = 7, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 6, N = 7, D = 6, M = 1, O = 0, R = 8, Y = 2 -S = 9, E = 6, N = 7, D = 5, M = 1, O = 0, R = 8, Y = 1 -S = 9, E = 6, N = 7, D = 4, M = 1, O = 0, R = 8, Y = 0 -S = 9, E = 5, N = 6, D = 9, M = 1, O = 0, R = 8, Y = 4 -S = 9, E = 5, N = 6, D = 8, M = 1, O = 0, R = 8, Y = 3 -S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 - -Ans: -S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/124 b/CLPQR/clpqr/examples/SESSION/124 deleted file mode 100644 index e8e044db4..000000000 --- a/CLPQR/clpqr/examples/SESSION/124 +++ /dev/null @@ -1,33 +0,0 @@ -/tmp/clpq - -yes -| ?- use_module(library('clpqr/monash')). -{compiling /freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl...} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/printf.ql in module printf, 40 msec 27216 bytes} -{loading /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql...} -{loaded /freyung/christian/sicstus2.1.9.clp/library/clpqr/expand.ql in module expand, 40 msec 26832 bytes} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/monash.pl compiled, 150 msec 54848 bytes} - -yes -| ?- expand, [library('clpqr/examples/monash/toolpath')], noexpand. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/toolpath...} -{Warning: [T] - singleton variables in lookup/2 in lines 20-22} -{Warning: [H] - singleton variables in lookup/2 in lines 22-24} -{Warning: [A,B,X,Y] - singleton variables in get_vars/2 in lines 42-43} -{Warning: [A,B,C,M] - singleton variables in get_vars/2 in lines 44-45} -{Warning: [Y2] - singleton variables in get_constraint/2 in lines 57-64} -{Warning: [C,M,N] - singleton variables in make_db/3 in lines 79-81} - ->>> Sample goal: go/0 -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/monash/toolpath consulted, 120 msec 9904 bytes} - -yes -| ?- go. -G00 X10.000 Y10.000 -G01 X10.000 Y20.000 -G01 X15.000 Y15.000 -G01 X10.000 Y10.000 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/130 b/CLPQR/clpqr/examples/SESSION/130 deleted file mode 100644 index 696673a3d..000000000 --- a/CLPQR/clpqr/examples/SESSION/130 +++ /dev/null @@ -1,27 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/caneghem')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/caneghem.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/caneghem.pl consulted, 2180 msec 74144 bytes} - -yes -| ?- time(caneghem(10,L)). -%%% Timing 00:00:00.160 0.160 - -L = [109809934394489/93030756563880,-52978607561087/279092269691640,-2162596837367/69773067422910,-1341902984327/139546134845820,3121499920478/34886533711455,-8117164888193/139546134845820,3580440337351/69773067422910,-188625944281/3876281523495,-2697505671511/27909226969164,15735980576941/139546134845820] ? - -yes -| ?- time(caneghem(20,L)). -%%% Timing 00:00:02.280 2.280 - -L = [1809569737312374554754004484225676083/1537182329904667436922324603713639776,-1271971484421143048427690477220730239/3458660242285501733075230358355689496,-95368336690805467404344473696923776/432332530285687716634403794794461187,998044385166530132547027343054105685/13834640969142006932300921433422757984,-189625378955883200330280178861532101/4611546989714002310766973811140919328,-57790424254171609267150236894469345/13834640969142006932300921433422757984,7032417616810428003871191570429803/144110843428562572211467931598153729,-928573560001628559951506469292773197/6917320484571003466150460716711378992,276951892494812019737330164001879005/13834640969142006932300921433422757984,529252842507055068067062514342509431/2305773494857001155383486905570459664,-1458842333142222064000440767724691093/13834640969142006932300921433422757984,886219254790287036074965602063208837/6917320484571003466150460716711378992,1166548370272449632355921183061243741/6917320484571003466150460716711378992,465082508157693680330155206617328665/6917320484571003466150460716711378992,-485173901705258259507302346892885751/6917320484571003466150460716711378992,77100498072274260628155738958749747/1537182329904667436922324603713639776,-880437096888643788826784982233347309/6917320484571003466150460716711378992,469663247152021437667674305838141839/3458660242285501733075230358355689496,1036489712401932754800051947708801131/6917320484571003466150460716711378992,-2444798529844666371510368456136857911/13834640969142006932300921433422757984] ? - -yes -| ?- time(caneghem(50,L)). -%%% Timing 00:02:12.040 132.040 - -L = [850702988455712049219959014709202045508702967377956940158040468926139358479509253862747026284152874891/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,162658242972644784084663454372497835588206570205271394512854117425185147611501484497147444108991546513/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,-111642637004745426434091278772613076667109308463100847716273964803388309141502893118982020642395798239/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-2927289223595360776467211823995063595175578078901376122899817801736323204261696356500733465372052282/42386933394020616123555712381477075341305508410230284195441362205927031166453906303445444929891844391,32772770036547430673820647543562830559989965861984712100603169296909469297629603879134012255952076845/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,4595822960808230767958280370936812208214311696405895172532020497021162970172988419337762217316187699/7371640590264454978009689109822100059357479723518310294859367340161222811557201096251381726937712068,198264147416126626237292126155177292590887154955190706681109510744356179570533295310874944201901281949/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,5611834796930579288641272881315923655901092780192180015241569465884467205160440484103831351118180471/42386933394020616123555712381477075341305508410230284195441362205927031166453906303445444929891844391,-14371654709386874792788607464015290662977744622618437478360058881795650388537026766561041118117172725/30826860650196811726222336277437872975494915207440206687593717967946931757421022766142141767194068648,11190675067845681752876425028607796186027097542902375160477810872389520333863594137536262864820651293/61653721300393623452444672554875745950989830414880413375187435935893863514842045532284283534388137296,-824644085588479161381409762271127121465091160155510883003997469458733504750523831674644719841256283/14743281180528909956019378219644200118714959447036620589718734680322445623114402192502763453875424136,1267179134558299997694619371374922887783662929591365287497193505876656294060547706840997660772434597/1842910147566113744502422277455525014839369930879577573714841835040305702889300274062845431734428017,-405622513034057034998767782312375977042073570679769897922393383996807890732336123955147248448417022613/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-56534930816835248292910016188861622746093160596135068069418548191223171194518276720165667477082373419/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,-83412644695404804443274610222458771661020661490440728515386116331210582576358411852045906883200568567/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,-8882916647439327286386207942662751793177872278991229789786609350896348273600975806870903732409350823/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,-1959129057517558190540937655930820371766886814268786644134442916184198763988525391936148623633450629/30826860650196811726222336277437872975494915207440206687593717967946931757421022766142141767194068648,-29117111872207285393073342746147666255297918706733463971216518606800227071751369614615166608607558775/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,-181056010230625766679294607071809620549634816765501325588371895383700694677949600096525153828644058713/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,305963730247867771942099413331952746256320331459705482265877713159490881083542337260531981120914659475/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,-17952457534403097298443573925610959782021553087921644289506291368179144428528899747705780604979512571/30826860650196811726222336277437872975494915207440206687593717967946931757421022766142141767194068648,111469039390835216440279057401501053111373333590209974889165581009289406011453762097360356390912662915/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,185840539480907727573994610158684887977585170340275520402696049836204008258183502077761488427607210367/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,13056730621608629311278924536856816978933280627653605759653337278287474326143201796107999871068984201/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,-608137808119077413565722757019119743418575493249410542902576319553283867810328291178092197665747246743/3051859204369484360896011291466349424573996605536580462071778078826746243984681253848072034952212796152,-4034577618734854192682004603713664099301964830180806763431454710249910049607610772455113319578812017/7706715162549202931555584069359468243873728801860051671898429491986732939355255691535535441798517162,374065745307968822711244330595266561598546175154718323422502051799944764037902375460533443385323145965/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-925559653578751646969077071655990276298922844892908142830754718198911886397608514133346108195302703/1842910147566113744502422277455525014839369930879577573714841835040305702889300274062845431734428017,50552011443651187005875771465776867883753117217890592722820149912308284964210203962427799436060640353/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,54387154280000524521874897642528211652930066480533179638706199370971208653254994202128295363621785915/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,-305660967155111540180653617813029146482286537492879408385393369123285052557673063257013600906059107789/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,50977872687663968474936178910302158838168787421276125244376403117956984679640751629937462692538650119/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,-11546873926699084374295170072945695921072253276886456857875426698369282270440312230963608081850842497/30826860650196811726222336277437872975494915207440206687593717967946931757421022766142141767194068648,-12463734977678436768462083893888420915557380486381140436902789997648254031978913060650446058233875203/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,-107213168861057267139802959967873255701868499237724883603517320794128012365733207333146717310001891473/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,12803675877838240493899562017153216748701193614831070205739123920440887053532185537531630920859698137/42386933394020616123555712381477075341305508410230284195441362205927031166453906303445444929891844391,118412894139936153112899618614011907439811179009343689830073070232262364049986630340500657826744932933/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-34985504325267181860621986301163584388402059458210701683148738646138377545086385182292228825870581197/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,-4907440255056363294884472335798129363079277480142296831787101562271891166383877700236237165153412635/30826860650196811726222336277437872975494915207440206687593717967946931757421022766142141767194068648,-32361537794571292902725549984023412844250525594726960742581201679693617102267289326127475601400043533/61653721300393623452444672554875745950989830414880413375187435935893863514842045532284283534388137296,93555507096390817382137783715155138794604668044359930252288738362845415897869955632181345498094608477/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-44184171165919685633220723691287456766956524870084083928885191444142819704930173988639211647254523477/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,-181164504139352324820032894034965287053705774314314055526816369383401106392440615417112800302137497965/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-17786574373964281870201064658906349840119724518729972244165507137550362072918922369632558300338363023/84773866788041232247111424762954150682611016820460568390882724411854062332907812606890889859783688782,60923780841545812535915493699736717917518021041164947374992186587168258633691460681301281123083885825/678190934304329857976891398103633205460888134563684547127061795294832498663262500855127118878269510256,-43142617128157042821042177156447152530395911233713473346788588628251419994788674965638385850529793983/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,96096793174691090228606744310537512938676587562057835437134726565457385524231716424110405738605490431/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-86244661159616143165935276333743420366665005417913143432500156105803534484288972578167824279968364019/169547733576082464494222849525908301365222033640921136781765448823708124665815625213781779719567377564,50776439271389273065195249050681754606251952874618598603770533033679530076453814675763488886495497869/339095467152164928988445699051816602730444067281842273563530897647416249331631250427563559439134755128,-9024426446380827955501687938780970257805575009431993606005405562994523212422198371256294185829567341/132689530624760189604174403976797801068434635023329585307468612122902010608029619732524871084878817224] ? - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/131 b/CLPQR/clpqr/examples/SESSION/131 deleted file mode 100644 index e68914b10..000000000 --- a/CLPQR/clpqr/examples/SESSION/131 +++ /dev/null @@ -1,32 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/matmul')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/matmul.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/matmul.pl consulted, 50 msec 5216 bytes} - -yes -| ?- inv_hilbert(5). -% took 130 msec -[25,-300,1050,-1400,630] -[-300,4800,-18900,26880,-12600] -[1050,-18900,79380,-117600,56700] -[-1400,26880,-117600,179200,-88200] -[630,-12600,56700,-88200,44100] - -yes -| ?- inv_hilbert(10). -% took 1410 msec -[100,-4950,79200,-600600,2522520,-6306300,9609600,-8751600,4375800,-923780] -[-4950,326700,-5880600,47567520,-208107900,535134600,-832431600,770140800,-389883780,83140200] -[79200,-5880600,112907520,-951350400,4281076800,-11237826600,17758540800,-16635041280,8506555200,-1829084400] -[-600600,47567520,-951350400,8245036800,-37875637800,101001700800,-161602721280,152907955200,-78843164400,17071454400] -[2522520,-208107900,4281076800,-37875637800,176752976400,-477233036280,771285715200,-735869534400,382086104400,-83223340200] -[-6306300,535134600,-11237826600,101001700800,-477233036280,1301544644400,-2121035716800,2037792556800,-1064382719400,233025352560] -[9609600,-832431600,17758540800,-161602721280,771285715200,-2121035716800,3480673996800,-3363975014400,1766086882560,-388375587600] -[-8751600,770140800,-16635041280,152907955200,-735869534400,2037792556800,-3363975014400,3267861442560,-1723286307600,380449555200] -[4375800,-389883780,8506555200,-78843164400,382086104400,-1064382719400,1766086882560,-1723286307600,912328045200,-202113826200] -[-923780,83140200,-1829084400,17071454400,-83223340200,233025352560,-388375587600,380449555200,-202113826200,44914183600] - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/132 b/CLPQR/clpqr/examples/SESSION/132 deleted file mode 100644 index 0a9cc6e82..000000000 --- a/CLPQR/clpqr/examples/SESSION/132 +++ /dev/null @@ -1,86 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/simplex')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/simplex.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/simplex.pl consulted, 240 msec 15360 bytes} - -yes -| ?- time(example(N,V,O)). -%%% Timing 00:00:00.020 0.020 - -N = 1, -O = 17200, -V = [40,160] ? ; -%%% Timing 00:00:00.040 0.040 - -N = 2, -O = 7, -V = [1,0,3/2] ? ; -%%% Timing 00:00:00.030 0.030 - -N = 3, -O = 18850, -V = [38,170] ? ; -%%% Timing 00:00:00.030 0.030 - -N = 4, -O = 310, -V = [7,2] ? ; -%%% Timing 00:00:00.030 0.030 - -N = 5, -O = 5, -V = [0,0,5/2] ? ; -%%% Timing 00:00:00.040 0.040 - -N = 6, -O = -7, -V = [1,0,3/2] ? ; -%%% Timing 00:00:00.110 0.110 - -N = 7, -O = -70, -V = [3,0,0,4,2,0,5] ? ; -%%% Timing 00:00:00.110 0.110 - -N = 8, -O = -39/2, -V = [0,7/2,0,0,0,1/2,0] ? ; -%%% Timing 00:00:00.410 0.410 - -N = 9, -O = 11429082625/9792, -V = [555967/58752,203455/39168,43955/3264,1175/272,705/68,0,60,3728575/58752,305075/4896,28375/408,2275/34,1200/17,0,0,0,0,0,24000/17] ? ; -%%% Timing 00:00:00.620 0.620 - -N = utility, -O = 977650/21, -V = [0,3400/21,200/7,1000/7,2000/3,0,0,0,1000,0,13400/7,13500/7,0,13900/7,4000,8350/21,45800/21,0,0,1000,500,2000,100,5000,250,600,800/7,0] ? ; -%%% Timing 00:00:00.330 0.330 - -N = electricity, -O = 109400/7, -V = [0,3000/7,200/7,_A,_B,0,0,0,_C,_D,_E,_F,_G,_H,1000,500,2000,100], -{_A+9/13*_G=<21400/91}, -{_G>=0}, -{_A>=0}, -{_D=1300/7+3/2*_A+1/2*_G}, -{_F=7900/7-_G}, -{_H=13900/7+_G}, -{_C=5700/7-3/2*_A-1/2*_G}, -{_E=13400/7-_G}, -{_B=3800/7-_A} ? ; -%%% Timing 00:00:00.440 0.440 - -N = water, -O = 23450, -V = [0,0,0,1000,0,0,50,_A,1000/3,_B,4000,0,7450/3,0,0,5000,250,600,_C,0], -{_C=5*_A}, -{_A>=0}, -{_B=1850/3-_A}, -{_A=<200/9} ? ; -%%% Timing 00:00:00.070 0.070 - -no -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/133 b/CLPQR/clpqr/examples/SESSION/133 deleted file mode 100644 index 847429795..000000000 --- a/CLPQR/clpqr/examples/SESSION/133 +++ /dev/null @@ -1,21 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/squares')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/squares.pl...} -{Warning: [X1,X2,X3,X4,X5,X6,X7,X8,X9] - singleton variables in rectangle/2 in lines 1-40} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/squares.pl consulted, 30 msec 2928 bytes} - -yes -| ?- time(rectangle(A,Rs)). -%%% Timing 00:01:10.950 70.950 - -A = 33/32, -Rs = [15/32,9/16,1/4,7/32,1/8,7/16,1/32,5/16,9/32] ? ; -%%% Timing 00:00:08.730 8.730 - -A = 69/61, -Rs = [33/61,36/61,28/61,5/61,2/61,9/61,25/61,7/61,16/61] ? - -yes -| ?- ^D diff --git a/CLPQR/clpqr/examples/SESSION/134 b/CLPQR/clpqr/examples/SESSION/134 deleted file mode 100644 index 9bc46d312..000000000 --- a/CLPQR/clpqr/examples/SESSION/134 +++ /dev/null @@ -1,52 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/mip')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/mip.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/mip.pl consulted, 2700 msec 97008 bytes} - -yes -| ?- example(1). -incumbent(14,[1,2]) -incumbent(13,[2,1]) -1:13 -%%% Timing 00:00:00.030 0.030 - -yes -| ?- example(2). -incumbent(-42,[0,2]) -2:-42 -%%% Timing 00:00:00.020 0.020 - -yes -| ?- example(flugpl). -incumbent(1202700,[71,70,70,60,60,0,8,7,16,6,6]) -incumbent(1202400,[72,70,70,60,60,0,9,7,16,6,6]) -incumbent(1202100,[73,70,70,60,60,0,10,7,16,6,6]) -incumbent(1201800,[74,70,70,60,60,0,11,7,16,6,6]) -incumbent(1201500,[75,70,70,60,60,0,12,7,16,6,6]) -flugpl:1201500 -%%% Timing 00:00:45.920 45.920 - -yes -| ?- example(flugplan). -incumbent(1202700,[70,7,70,8,71,0,6,60,6,60,16]) -incumbent(1202400,[70,7,70,9,72,0,6,60,6,60,16]) -incumbent(1202100,[70,7,70,10,73,0,6,60,6,60,16]) -incumbent(1201800,[70,7,70,11,74,0,6,60,6,60,16]) -incumbent(1201500,[70,7,70,12,75,0,6,60,6,60,16]) -flugplan:1201500 -%%% Timing 00:00:19.230 19.230 - -yes -| ?- example(sample2). -incumbent(450,[0,0,1,1,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,1,0]) -incumbent(430,[0,0,1,0,0,0,1,0,1,0,1,0,0,1,1,1,0,0,0,1,0]) -incumbent(400,[0,0,1,0,0,0,1,1,0,0,1,0,0,1,1,0,1,0,0,1,0]) -incumbent(385,[0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,0,1,0,1,0]) -incumbent(375,[0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,0,0,0,1,0,0]) -sample2:375 -%%% Timing 00:00:58.940 58.940 - -yes -| ?- diff --git a/CLPQR/clpqr/examples/SESSION/135 b/CLPQR/clpqr/examples/SESSION/135 deleted file mode 100644 index 6ef0f633a..000000000 --- a/CLPQR/clpqr/examples/SESSION/135 +++ /dev/null @@ -1,256 +0,0 @@ -/tmp/clpq - -yes -| ?- [library('clpqr/examples/eliminat')]. -{consulting /freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/eliminat.pl...} -{/freyung/christian/sicstus2.1.9.clp/library/clpqr/examples/eliminat.pl consulted, 200 msec 15600 bytes} - -yes -| ?- hull([X,Y]). - -{Y=<2}, -{X+1/2*Y=<3}, -{X>=1}, -{Y>=0}, -{X+Y>=2} ? - -yes -| ?- example(1,[_,_,X3,X4]). - -{X3-1/3*X4>=-1/3}, -{X3-11/9*X4=<1/9}, -{X3-8/9*X4=<1/9}, -{X3-13/18*X4>=-2/9}, -{X3-1/6*X4=<1/3} ? - -yes -| ?- example(2,[X0,X1|_]). - -{X0+2619277/17854273*X1>=-851123/17854273}, -{X0+6429953/16575801*X1=<-12749681/16575801}, -{X0+19130/1213083*X1>=795400/404361}, -{X0-1251619/3956679*X1>=21101146/3956679}, -{X0+601502/4257189*X1>=220850/473021} ? - -yes -| ?- proj(1). -%%% Timing 00:00:00.100 0.100 -[A,B,C,D]:6 -{B>=0} -{A>=0} -{D-3*C+B+12*A=<1} -{D-9/7*C+1/7*B+18/7*A>=1/7} -{D-18/11*C+2/11*B+36/11*A>=2/11} -{D-18/13*C+4/13*B+45/13*A=<4/13} - -%%% Timing 00:00:00.270 0.270 -[A,B,C]:6 -{A>=0} -{C-6*B-2*A>=-2} -{C-18/13*B+4/13*A=<4/13} -{C-9/11*B-1/11*A>=-1/11} -{C-9/8*B-1/8*A>=-1/8} -{C-3*B+A=<1} - -%%% Timing 00:00:00.320 0.320 -[A,B]:5 -{B-3*A=<1} -{B-9/11*A>=-1/11} -{B-9/8*A>=-1/8} -{B-18/13*A=<4/13} -{B-6*A>=-2} - -%%% Timing 00:00:00.290 0.290 -[A]:2 -{A=<1} -{A>=-1/2} - -%%% Timing 00:00:00.030 0.030 -[]:0 - -%%% Timing 00:00:00.260 0.260 -[A]:2 -{A=<1/2} -{A>=-1/2} - -%%% Timing 00:00:00.250 0.250 -[A,B]:3 -{A>=0} -{B-1/2*A>=-1/2} -{B+A=<1} - -%%% Timing 00:00:00.190 0.190 -[A]:2 -{A>=0} -{A=<1} - -%%% Timing 00:00:00.270 0.270 -[A,B]:3 -{A>=0} -{B-1/2*A>=-1/2} -{B+1/2*A=<1/2} - -%%% Timing 00:00:00.260 0.260 -[A,B,C]:6 -{A>=0} -{C-2*B+3*A>=0} -{C-18/13*B+45/13*A=<4/13} -{C-B+A>=0} -{C-4/3*B+4/3*A>=0} -{C-3*B+12*A=<1} - -%%% Timing 00:00:00.250 0.250 -[A,B]:4 -{A>=0} -{B-36/5*A>=-4/5} -{B-9/2*A>=-1/2} -{B+9/2*A=<1} - -%%% Timing 00:00:00.200 0.200 -[A]:2 -{A>=0} -{A=<2/13} - -%%% Timing 00:00:00.230 0.230 -[A,B]:4 -{A>=0} -{B-32/5*A>=-3/5} -{B-11/2*A>=-1/2} -{B+3/4*A=<1/2} - -%%% Timing 00:00:00.230 0.230 -[A,B,C]:5 -{B>=0} -{A>=0} -{C+B+9/2*A=<1} -{C-1/2*B-9/2*A>=-1/2} -{C-4/5*B-36/5*A>=-4/5} - -%%% Timing 00:00:00.200 0.200 -[A,B]:3 -{B>=0} -{A>=0} -{B+13/2*A=<1} - -%%% Timing 00:00:00.210 0.210 -[A,B,C]:5 -{B>=0} -{A>=0} -{C+1/2*B+3/4*A=<1/2} -{C-1/2*B-11/2*A>=-1/2} -{C-3/5*B-32/5*A>=-3/5} - -%%% Timing 00:00:00.000 0.000 - -no -| ?- proj(3). -%%% Timing 00:00:00.100 0.100 -[A,B,C,D]:6 -{B>=0} -{A>0} -{D-3*C+B+12*A=<1} -{D-9/7*C+1/7*B+18/7*A>=1/7} -{D-18/11*C+2/11*B+36/11*A>=2/11} -{D-18/13*C+4/13*B+45/13*A=<4/13} - -%%% Timing 00:00:00.260 0.260 -[A,B,C]:6 -{A>=0} -{C-6*B-2*A>=-2} -{C-18/13*B+4/13*A<4/13} -{C-9/11*B-1/11*A>=-1/11} -{C-9/8*B-1/8*A>=-1/8} -{C-3*B+A<1} - -%%% Timing 00:00:00.290 0.290 -[A,B]:5 -{B-3*A<1} -{B-9/11*A>=-1/11} -{B-9/8*A>=-1/8} -{B-18/13*A<4/13} -{B-6*A>=-2} - -%%% Timing 00:00:00.280 0.280 -[A]:2 -{A<1} -{A>-1/2} - -%%% Timing 00:00:00.040 0.040 -[]:0 - -%%% Timing 00:00:00.250 0.250 -[A]:2 -{A<1/2} -{A>-1/2} - -%%% Timing 00:00:00.260 0.260 -[A,B]:3 -{A>=0} -{B-1/2*A>-1/2} -{B+A<1} - -%%% Timing 00:00:00.190 0.190 -[A]:2 -{A>=0} -{A<1} - -%%% Timing 00:00:00.260 0.260 -[A,B]:3 -{A>=0} -{B-1/2*A>-1/2} -{B+1/2*A<1/2} - -%%% Timing 00:00:00.260 0.260 -[A,B,C]:6 -{A>0} -{C-2*B+3*A>=0} -{C-18/13*B+45/13*A=<4/13} -{C-B+A>=0} -{C-4/3*B+4/3*A>=0} -{C-3*B+12*A=<1} - -%%% Timing 00:00:00.260 0.260 -[A,B]:4 -{A>0} -{B-36/5*A>=-4/5} -{B-9/2*A>=-1/2} -{B+9/2*A=<1} - -%%% Timing 00:00:00.210 0.210 -[A]:2 -{A>0} -{A=<2/13} - -%%% Timing 00:00:00.230 0.230 -[A,B]:4 -{A>0} -{B-32/5*A>=-3/5} -{B-11/2*A>=-1/2} -{B+3/4*A=<1/2} - -%%% Timing 00:00:00.220 0.220 -[A,B,C]:5 -{B>=0} -{A>0} -{C+B+9/2*A=<1} -{C-1/2*B-9/2*A>=-1/2} -{C-4/5*B-36/5*A>=-4/5} - -%%% Timing 00:00:00.200 0.200 -[A,B]:3 -{B>=0} -{A>0} -{B+13/2*A=<1} - -%%% Timing 00:00:00.230 0.230 -[A,B,C]:5 -{B>=0} -{A>0} -{C+1/2*B+3/4*A=<1/2} -{C-1/2*B-11/2*A>=-1/2} -{C-3/5*B-32/5*A>=-3/5} - -%%% Timing 00:00:00.020 0.020 - -no -| ?- diff --git a/CLPQR/clpqr/examples/caneghem.pl b/CLPQR/clpqr/examples/caneghem.pl deleted file mode 100644 index 35f958f89..000000000 --- a/CLPQR/clpqr/examples/caneghem.pl +++ /dev/null @@ -1,105 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: caneghem.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -caneghem(10,[_176,_178,_180,_182,_184,_186,_188,_190,_192,_194]) :- - { - _176*1 + _178*1 + _180*1 + _182*1 + _184*1 + _186*1 + _188*1 + _190*1 + _192*1 + _194*1 = 1, - _176*2 + _178*4 + _180*8 + _182*16 + _184*32 + _186*64 + _188*27 + _190*54 + _192*7 + _194*14 = 0, - _176*3 + _178*9 + _180*27 + _182*81 + _184*41 + _186*22 + _188*66 + _190*97 + _192*89 + _194*65 = 0, - _176*4 + _178*16 + _180*64 + _182*54 + _184*14 + _186*56 + _188*22 + _190*88 + _192*49 + _194*95 = 0, - _176*5 + _178*25 + _180*24 + _182*19 + _184*95 + _186*71 + _188*52 + _190*58 + _192*88 + _194*36 = 0, - _176*6 + _178*36 + _180*14 + _182*84 + _184*100 + _186*95 + _188*65 + _190*87 + _192*17 + _194*1 = 0, - _176*7 + _178*49 + _180*40 + _182*78 + _184*41 + _186*85 + _188*90 + _190*24 + _192*67 + _194*65 = 0, - _176*8 + _178*64 + _180*7 + _182*56 + _184*44 + _186*49 + _188*89 + _190*5 + _192*40 + _194*17 = 0, - _176*9 + _178*81 + _180*22 + _182*97 + _184*65 + _186*80 + _188*13 + _190*16 + _192*43 + _194*84 = 0, - _176*10 + _178*100 + _180*91 + _182*1 + _184*10 + _186*100 + _188*91 + _190*1 + _192*10 + _194*100 = 0 - }. - -caneghem(20,[_176,_178,_180,_182,_184,_186,_188,_190,_192,_194,_196,_198,_200,_202,_204,_206,_208,_210,_212,_214]) :- - { - _176*1 + _178*1 + _180*1 + _182*1 + _184*1 + _186*1 + _188*1 + _190*1 + _192*1 + _194*1 + _196*1 + _198*1 + _200*1 + _202*1 + _204*1 + _206*1 + _208*1 + _210*1 + _212*1 + _214*1 = 1, - _176*2 + _178*4 + _180*8 + _182*16 + _184*32 + _186*64 + _188*27 + _190*54 + _192*7 + _194*14 + _196*28 + _198*56 + _200*11 + _202*22 + _204*44 + _206*88 + _208*75 + _210*49 + _212*98 + _214*95 = 0, - _176*3 + _178*9 + _180*27 + _182*81 + _184*41 + _186*22 + _188*66 + _190*97 + _192*89 + _194*65 + _196*94 + _198*80 + _200*38 + _202*13 + _204*39 + _206*16 + _208*48 + _210*43 + _212*28 + _214*84 = 0, - _176*4 + _178*16 + _180*64 + _182*54 + _184*14 + _186*56 + _188*22 + _190*88 + _192*49 + _194*95 + _196*77 + _198*5 + _200*20 + _202*80 + _204*17 + _206*68 + _208*70 + _210*78 + _212*9 + _214*36 = 0, - _176*5 + _178*25 + _180*24 + _182*19 + _184*95 + _186*71 + _188*52 + _190*58 + _192*88 + _194*36 + _196*79 + _198*92 + _200*56 + _202*78 + _204*87 + _206*31 + _208*54 + _210*68 + _212*37 + _214*84 = 0, - _176*6 + _178*36 + _180*14 + _182*84 + _184*100 + _186*95 + _188*65 + _190*87 + _192*17 + _194*1 + _196*6 + _198*36 + _200*14 + _202*84 + _204*100 + _206*95 + _208*65 + _210*87 + _212*17 + _214*1 = 0, - _176*7 + _178*49 + _180*40 + _182*78 + _184*41 + _186*85 + _188*90 + _190*24 + _192*67 + _194*65 + _196*51 + _198*54 + _200*75 + _202*20 + _204*39 + _206*71 + _208*93 + _210*45 + _212*12 + _214*84 = 0, - _176*8 + _178*64 + _180*7 + _182*56 + _184*44 + _186*49 + _188*89 + _190*5 + _192*40 + _194*17 + _196*35 + _198*78 + _200*18 + _202*43 + _204*41 + _206*25 + _208*99 + _210*85 + _212*74 + _214*87 = 0, - _176*9 + _178*81 + _180*22 + _182*97 + _184*65 + _186*80 + _188*13 + _190*16 + _192*43 + _194*84 + _196*49 + _198*37 + _200*30 + _202*68 + _204*6 + _206*54 + _208*82 + _210*31 + _212*77 + _214*87 = 0, - _176*10 + _178*100 + _180*91 + _182*1 + _184*10 + _186*100 + _188*91 + _190*1 + _192*10 + _194*100 + _196*91 + _198*1 + _200*10 + _202*100 + _204*91 + _206*1 + _208*10 + _210*100 + _212*91 + _214*1 = 0, - _176*11 + _178*20 + _180*18 + _182*97 + _184*57 + _186*21 + _188*29 + _190*16 + _192*75 + _194*17 + _196*86 + _198*37 + _200*3 + _202*33 + _204*60 + _206*54 + _208*89 + _210*70 + _212*63 + _214*87 = 0, - _176*12 + _178*43 + _180*11 + _182*31 + _184*69 + _186*20 + _188*38 + _190*52 + _192*18 + _194*14 + _196*67 + _198*97 + _200*53 + _202*30 + _204*57 + _206*78 + _208*27 + _210*21 + _212*50 + _214*95 = 0, - _176*13 + _178*68 + _180*76 + _182*79 + _184*17 + _186*19 + _188*45 + _190*80 + _192*30 + _194*87 + _196*20 + _198*58 + _200*47 + _202*5 + _204*65 + _206*37 + _208*77 + _210*92 + _212*85 + _214*95 = 0, - _176*14 + _178*95 + _180*17 + _182*36 + _184*100 + _186*87 + _188*6 + _190*84 + _192*65 + _194*1 + _196*14 + _198*95 + _200*17 + _202*36 + _204*100 + _206*87 + _208*6 + _210*84 + _212*65 + _214*1 = 0, - _176*15 + _178*23 + _180*42 + _182*24 + _184*57 + _186*47 + _188*99 + _190*71 + _192*55 + _194*17 + _196*53 + _198*88 + _200*7 + _202*4 + _204*60 + _206*92 + _208*67 + _210*96 + _212*26 + _214*87 = 0, - _176*16 + _178*54 + _180*56 + _182*88 + _184*95 + _186*5 + _188*80 + _190*68 + _192*78 + _194*36 + _196*71 + _198*25 + _200*97 + _202*37 + _204*87 + _206*79 + _208*52 + _210*24 + _212*81 + _214*84 = 0, - _176*17 + _178*87 + _180*65 + _182*95 + _184*100 + _186*84 + _188*14 + _190*36 + _192*6 + _194*1 + _196*17 + _198*87 + _200*65 + _202*95 + _204*100 + _206*84 + _208*14 + _210*36 + _212*6 + _214*1 = 0, - _176*18 + _178*21 + _180*75 + _182*37 + _184*60 + _186*70 + _188*48 + _190*56 + _192*99 + _194*65 + _196*59 + _198*52 + _200*27 + _202*82 + _204*62 + _206*5 + _208*90 + _210*4 + _212*72 + _214*84 = 0, - _176*19 + _178*58 + _180*92 + _182*31 + _184*84 + _186*81 + _188*24 + _190*52 + _192*79 + _194*87 + _196*37 + _198*97 + _200*25 + _202*71 + _204*36 + _206*78 + _208*68 + _210*80 + _212*5 + _214*95 = 0, - _176*20 + _178*97 + _180*21 + _182*16 + _184*17 + _186*37 + _188*33 + _190*54 + _192*70 + _194*87 + _196*23 + _198*56 + _200*9 + _202*79 + _204*65 + _206*88 + _208*43 + _210*52 + _212*30 + _214*95 = 0 - }. - -caneghem(50,[_108,_110,_112,_114,_116,_118,_120,_122,_124,_126,_128,_130,_132,_134,_136,_138,_140,_142,_144,_146,_148,_150,_152,_154,_156,_158,_160,_162,_164,_166,_168,_170,_172,_174,_176,_178,_180,_182,_184,_186,_188,_190,_192,_194,_196,_198,_200,_202,_204,_206]) :- - { - _108*1 + _110*1 + _112*1 + _114*1 + _116*1 + _118*1 + _120*1 + _122*1 + _124*1 + _126*1 + _128*1 + _130*1 + _132*1 + _134*1 + _136*1 + _138*1 + _140*1 + _142*1 + _144*1 + _146*1 + _148*1 + _150*1 + _152*1 + _154*1 + _156*1 + _158*1 + _160*1 + _162*1 + _164*1 + _166*1 + _168*1 + _170*1 + _172*1 + _174*1 + _176*1 + _178*1 + _180*1 + _182*1 + _184*1 + _186*1 + _188*1 + _190*1 + _192*1 + _194*1 + _196*1 + _198*1 + _200*1 + _202*1 + _204*1 + _206*1 = 1, - _108*2 + _110*4 + _112*8 + _114*16 + _116*32 + _118*64 + _120*27 + _122*54 + _124*7 + _126*14 + _128*28 + _130*56 + _132*11 + _134*22 + _136*44 + _138*88 + _140*75 + _142*49 + _144*98 + _146*95 + _148*89 + _150*77 + _152*53 + _154*5 + _156*10 + _158*20 + _160*40 + _162*80 + _164*59 + _166*17 + _168*34 + _170*68 + _172*35 + _174*70 + _176*39 + _178*78 + _180*55 + _182*9 + _184*18 + _186*36 + _188*72 + _190*43 + _192*86 + _194*71 + _196*41 + _198*82 + _200*63 + _202*25 + _204*50 + _206*100 = 0, - _108*3 + _110*9 + _112*27 + _114*81 + _116*41 + _118*22 + _120*66 + _122*97 + _124*89 + _126*65 + _128*94 + _130*80 + _132*38 + _134*13 + _136*39 + _138*16 + _140*48 + _142*43 + _144*28 + _146*84 + _148*50 + _150*49 + _152*46 + _154*37 + _156*10 + _158*30 + _160*90 + _162*68 + _164*2 + _166*6 + _168*18 + _170*54 + _172*61 + _174*82 + _176*44 + _178*31 + _180*93 + _182*77 + _184*29 + _186*87 + _188*59 + _190*76 + _192*26 + _194*78 + _196*32 + _198*96 + _200*86 + _202*56 + _204*67 + _206*100 = 0, - _108*4 + _110*16 + _112*64 + _114*54 + _116*14 + _118*56 + _120*22 + _122*88 + _124*49 + _126*95 + _128*77 + _130*5 + _132*20 + _134*80 + _136*17 + _138*68 + _140*70 + _142*78 + _144*9 + _146*36 + _148*43 + _150*71 + _152*82 + _154*25 + _156*100 + _158*97 + _160*85 + _162*37 + _164*47 + _166*87 + _168*45 + _170*79 + _172*13 + _174*52 + _176*6 + _178*24 + _180*96 + _182*81 + _184*21 + _186*84 + _188*33 + _190*31 + _192*23 + _194*92 + _196*65 + _198*58 + _200*30 + _202*19 + _204*76 + _206*1 = 0, - _108*5 + _110*25 + _112*24 + _114*19 + _116*95 + _118*71 + _120*52 + _122*58 + _124*88 + _126*36 + _128*79 + _130*92 + _132*56 + _134*78 + _136*87 + _138*31 + _140*54 + _142*68 + _144*37 + _146*84 + _148*16 + _150*80 + _152*97 + _154*81 + _156*1 + _158*5 + _160*25 + _162*24 + _164*19 + _166*95 + _168*71 + _170*52 + _172*58 + _174*88 + _176*36 + _178*79 + _180*92 + _182*56 + _184*78 + _186*87 + _188*31 + _190*54 + _192*68 + _194*37 + _196*84 + _198*16 + _200*80 + _202*97 + _204*81 + _206*1 = 0, - _108*6 + _110*36 + _112*14 + _114*84 + _116*100 + _118*95 + _120*65 + _122*87 + _124*17 + _126*1 + _128*6 + _130*36 + _132*14 + _134*84 + _136*100 + _138*95 + _140*65 + _142*87 + _144*17 + _146*1 + _148*6 + _150*36 + _152*14 + _154*84 + _156*100 + _158*95 + _160*65 + _162*87 + _164*17 + _166*1 + _168*6 + _170*36 + _172*14 + _174*84 + _176*100 + _178*95 + _180*65 + _182*87 + _184*17 + _186*1 + _188*6 + _190*36 + _192*14 + _194*84 + _196*100 + _198*95 + _200*65 + _202*87 + _204*17 + _206*1 = 0, - _108*7 + _110*49 + _112*40 + _114*78 + _116*41 + _118*85 + _120*90 + _122*24 + _124*67 + _126*65 + _128*51 + _130*54 + _132*75 + _134*20 + _136*39 + _138*71 + _140*93 + _142*45 + _144*12 + _146*84 + _148*83 + _150*76 + _152*27 + _154*88 + _156*10 + _158*70 + _160*86 + _162*97 + _164*73 + _166*6 + _168*42 + _170*92 + _172*38 + _174*64 + _176*44 + _178*5 + _180*35 + _182*43 + _184*99 + _186*87 + _188*3 + _190*21 + _192*46 + _194*19 + _196*32 + _198*22 + _200*53 + _202*68 + _204*72 + _206*100 = 0, - _108*8 + _110*64 + _112*7 + _114*56 + _116*44 + _118*49 + _120*89 + _122*5 + _124*40 + _126*17 + _128*35 + _130*78 + _132*18 + _134*43 + _136*41 + _138*25 + _140*99 + _142*85 + _144*74 + _146*87 + _148*90 + _150*13 + _152*3 + _154*24 + _156*91 + _158*21 + _160*67 + _162*31 + _164*46 + _166*65 + _168*15 + _170*19 + _172*51 + _174*4 + _176*32 + _178*54 + _180*28 + _182*22 + _184*75 + _186*95 + _188*53 + _190*20 + _192*59 + _194*68 + _196*39 + _198*9 + _200*72 + _202*71 + _204*63 + _206*100 = 0, - _108*9 + _110*81 + _112*22 + _114*97 + _116*65 + _118*80 + _120*13 + _122*16 + _124*43 + _126*84 + _128*49 + _130*37 + _132*30 + _134*68 + _136*6 + _138*54 + _140*82 + _142*31 + _144*77 + _146*87 + _148*76 + _150*78 + _152*96 + _154*56 + _156*100 + _158*92 + _160*20 + _162*79 + _164*4 + _166*36 + _168*21 + _170*88 + _172*85 + _174*58 + _176*17 + _178*52 + _180*64 + _182*71 + _184*33 + _186*95 + _188*47 + _190*19 + _192*70 + _194*24 + _196*14 + _198*25 + _200*23 + _202*5 + _204*45 + _206*1 = 0, - _108*10 + _110*100 + _112*91 + _114*1 + _116*10 + _118*100 + _120*91 + _122*1 + _124*10 + _126*100 + _128*91 + _130*1 + _132*10 + _134*100 + _136*91 + _138*1 + _140*10 + _142*100 + _144*91 + _146*1 + _148*10 + _150*100 + _152*91 + _154*1 + _156*10 + _158*100 + _160*91 + _162*1 + _164*10 + _166*100 + _168*91 + _170*1 + _172*10 + _174*100 + _176*91 + _178*1 + _180*10 + _182*100 + _184*91 + _186*1 + _188*10 + _190*100 + _192*91 + _194*1 + _196*10 + _198*100 + _200*91 + _202*1 + _204*10 + _206*100 = 0, - _108*11 + _110*20 + _112*18 + _114*97 + _116*57 + _118*21 + _120*29 + _122*16 + _124*75 + _126*17 + _128*86 + _130*37 + _132*3 + _134*33 + _136*60 + _138*54 + _140*89 + _142*70 + _144*63 + _146*87 + _148*48 + _150*23 + _152*51 + _154*56 + _156*10 + _158*9 + _160*99 + _162*79 + _164*61 + _166*65 + _168*8 + _170*88 + _172*59 + _174*43 + _176*69 + _178*52 + _180*67 + _182*30 + _184*27 + _186*95 + _188*35 + _190*82 + _192*94 + _194*24 + _196*62 + _198*76 + _200*28 + _202*5 + _204*55 + _206*100 = 0, - _108*12 + _110*43 + _112*11 + _114*31 + _116*69 + _118*20 + _120*38 + _122*52 + _124*18 + _126*14 + _128*67 + _130*97 + _132*53 + _134*30 + _136*57 + _138*78 + _140*27 + _142*21 + _144*50 + _146*95 + _148*29 + _150*45 + _152*35 + _154*16 + _156*91 + _158*82 + _160*75 + _162*92 + _164*94 + _166*17 + _168*2 + _170*24 + _172*86 + _174*22 + _176*62 + _178*37 + _180*40 + _182*76 + _184*3 + _186*36 + _188*28 + _190*33 + _192*93 + _194*5 + _196*60 + _198*13 + _200*55 + _202*54 + _204*42 + _206*100 = 0, - _108*13 + _110*68 + _112*76 + _114*79 + _116*17 + _118*19 + _120*45 + _122*80 + _124*30 + _126*87 + _128*20 + _130*58 + _132*47 + _134*5 + _136*65 + _138*37 + _140*77 + _142*92 + _144*85 + _146*95 + _148*23 + _150*97 + _152*49 + _154*31 + _156*100 + _158*88 + _160*33 + _162*25 + _164*22 + _166*84 + _168*82 + _170*56 + _172*21 + _174*71 + _176*14 + _178*81 + _180*43 + _182*54 + _184*96 + _186*36 + _188*64 + _190*24 + _192*9 + _194*16 + _196*6 + _198*78 + _200*4 + _202*52 + _204*70 + _206*1 = 0, - _108*14 + _110*95 + _112*17 + _114*36 + _116*100 + _118*87 + _120*6 + _122*84 + _124*65 + _126*1 + _128*14 + _130*95 + _132*17 + _134*36 + _136*100 + _138*87 + _140*6 + _142*84 + _144*65 + _146*1 + _148*14 + _150*95 + _152*17 + _154*36 + _156*100 + _158*87 + _160*6 + _162*84 + _164*65 + _166*1 + _168*14 + _170*95 + _172*17 + _174*36 + _176*100 + _178*87 + _180*6 + _182*84 + _184*65 + _186*1 + _188*14 + _190*95 + _192*17 + _194*36 + _196*100 + _198*87 + _200*6 + _202*84 + _204*65 + _206*1 = 0, - _108*15 + _110*23 + _112*42 + _114*24 + _116*57 + _118*47 + _120*99 + _122*71 + _124*55 + _126*17 + _128*53 + _130*88 + _132*7 + _134*4 + _136*60 + _138*92 + _140*67 + _142*96 + _144*26 + _146*87 + _148*93 + _150*82 + _152*18 + _154*68 + _156*10 + _158*49 + _160*28 + _162*16 + _164*38 + _166*65 + _168*66 + _170*81 + _172*3 + _174*45 + _176*69 + _178*25 + _180*72 + _182*70 + _184*40 + _186*95 + _188*11 + _190*64 + _192*51 + _194*58 + _196*62 + _198*21 + _200*12 + _202*79 + _204*74 + _206*100 = 0, - _108*16 + _110*54 + _112*56 + _114*88 + _116*95 + _118*5 + _120*80 + _122*68 + _124*78 + _126*36 + _128*71 + _130*25 + _132*97 + _134*37 + _136*87 + _138*79 + _140*52 + _142*24 + _144*81 + _146*84 + _148*31 + _150*92 + _152*58 + _154*19 + _156*1 + _158*16 + _160*54 + _162*56 + _164*88 + _166*95 + _168*5 + _170*80 + _172*68 + _174*78 + _176*36 + _178*71 + _180*25 + _182*97 + _184*37 + _186*87 + _188*79 + _190*52 + _192*24 + _194*81 + _196*84 + _198*31 + _200*92 + _202*58 + _204*19 + _206*1 = 0, - _108*17 + _110*87 + _112*65 + _114*95 + _116*100 + _118*84 + _120*14 + _122*36 + _124*6 + _126*1 + _128*17 + _130*87 + _132*65 + _134*95 + _136*100 + _138*84 + _140*14 + _142*36 + _144*6 + _146*1 + _148*17 + _150*87 + _152*65 + _154*95 + _156*100 + _158*84 + _160*14 + _162*36 + _164*6 + _166*1 + _168*17 + _170*87 + _172*65 + _174*95 + _176*100 + _178*84 + _180*14 + _182*36 + _184*6 + _186*1 + _188*17 + _190*87 + _192*65 + _194*95 + _196*100 + _198*84 + _200*14 + _202*36 + _204*6 + _206*1 = 0, - _108*18 + _110*21 + _112*75 + _114*37 + _116*60 + _118*70 + _120*48 + _122*56 + _124*99 + _126*65 + _128*59 + _130*52 + _132*27 + _134*82 + _136*62 + _138*5 + _140*90 + _142*4 + _144*72 + _146*84 + _148*98 + _150*47 + _152*38 + _154*78 + _156*91 + _158*22 + _160*93 + _162*58 + _164*34 + _166*6 + _168*7 + _170*25 + _172*46 + _174*20 + _176*57 + _178*16 + _180*86 + _182*33 + _184*89 + _186*87 + _188*51 + _190*9 + _192*61 + _194*88 + _196*69 + _198*30 + _200*35 + _202*24 + _204*28 + _206*100 = 0, - _108*19 + _110*58 + _112*92 + _114*31 + _116*84 + _118*81 + _120*24 + _122*52 + _124*79 + _126*87 + _128*37 + _130*97 + _132*25 + _134*71 + _136*36 + _138*78 + _140*68 + _142*80 + _144*5 + _146*95 + _148*88 + _150*56 + _152*54 + _154*16 + _156*1 + _158*19 + _160*58 + _162*92 + _164*31 + _166*84 + _168*81 + _170*24 + _172*52 + _174*79 + _176*87 + _178*37 + _180*97 + _182*25 + _184*71 + _186*36 + _188*78 + _190*68 + _192*80 + _194*5 + _196*95 + _198*88 + _200*56 + _202*54 + _204*16 + _206*1 = 0, - _108*20 + _110*97 + _112*21 + _114*16 + _116*17 + _118*37 + _120*33 + _122*54 + _124*70 + _126*87 + _128*23 + _130*56 + _132*9 + _134*79 + _136*65 + _138*88 + _140*43 + _142*52 + _144*30 + _146*95 + _148*82 + _150*24 + _152*76 + _154*5 + _156*100 + _158*81 + _160*4 + _162*80 + _164*85 + _166*84 + _168*64 + _170*68 + _172*47 + _174*31 + _176*14 + _178*78 + _180*45 + _182*92 + _184*22 + _186*36 + _188*13 + _190*58 + _192*49 + _194*71 + _196*6 + _198*19 + _200*77 + _202*25 + _204*96 + _206*1 = 0, - _108*21 + _110*37 + _112*70 + _114*56 + _116*65 + _118*52 + _120*82 + _122*5 + _124*4 + _126*84 + _128*47 + _130*78 + _132*22 + _134*58 + _136*6 + _138*25 + _140*20 + _142*16 + _144*33 + _146*87 + _148*9 + _150*88 + _152*30 + _154*24 + _156*100 + _158*80 + _160*64 + _162*31 + _164*45 + _166*36 + _168*49 + _170*19 + _172*96 + _174*97 + _176*17 + _178*54 + _180*23 + _182*79 + _184*43 + _186*95 + _188*76 + _190*81 + _192*85 + _194*68 + _196*14 + _198*92 + _200*13 + _202*71 + _204*77 + _206*1 = 0, - _108*22 + _110*80 + _112*43 + _114*37 + _116*6 + _118*31 + _120*76 + _122*56 + _124*20 + _126*36 + _128*85 + _130*52 + _132*33 + _134*19 + _136*14 + _138*5 + _140*9 + _142*97 + _144*13 + _146*84 + _148*30 + _150*54 + _152*77 + _154*78 + _156*100 + _158*79 + _160*21 + _162*58 + _164*64 + _166*95 + _168*70 + _170*25 + _172*45 + _174*81 + _176*65 + _178*16 + _180*49 + _182*68 + _184*82 + _186*87 + _188*96 + _190*92 + _192*4 + _194*88 + _196*17 + _198*71 + _200*47 + _202*24 + _204*23 + _206*1 = 0, - _108*23 + _110*24 + _112*47 + _114*71 + _116*17 + _118*88 + _120*4 + _122*92 + _124*96 + _126*87 + _128*82 + _130*68 + _132*49 + _134*16 + _136*65 + _138*81 + _140*45 + _142*25 + _144*70 + _146*95 + _148*64 + _150*58 + _152*21 + _154*79 + _156*100 + _158*78 + _160*77 + _162*54 + _164*30 + _166*84 + _168*13 + _170*97 + _172*9 + _174*5 + _176*14 + _178*19 + _180*33 + _182*52 + _184*85 + _186*36 + _188*20 + _190*56 + _192*76 + _194*31 + _196*6 + _198*37 + _200*43 + _202*80 + _204*22 + _206*1 = 0, - _108*24 + _110*71 + _112*88 + _114*92 + _116*87 + _118*68 + _120*16 + _122*81 + _124*25 + _126*95 + _128*58 + _130*79 + _132*78 + _134*54 + _136*84 + _138*97 + _140*5 + _142*19 + _144*52 + _146*36 + _148*56 + _150*31 + _152*37 + _154*80 + _156*1 + _158*24 + _160*71 + _162*88 + _164*92 + _166*87 + _168*68 + _170*16 + _172*81 + _174*25 + _176*95 + _178*58 + _180*79 + _182*78 + _184*54 + _186*84 + _188*97 + _190*5 + _192*19 + _194*52 + _196*36 + _198*56 + _200*31 + _202*37 + _204*80 + _206*1 = 0, - _108*25 + _110*19 + _112*71 + _114*58 + _116*36 + _118*92 + _120*78 + _122*31 + _124*68 + _126*84 + _128*80 + _130*81 + _132*5 + _134*24 + _136*95 + _138*52 + _140*88 + _142*79 + _144*56 + _146*87 + _148*54 + _150*37 + _152*16 + _154*97 + _156*1 + _158*25 + _160*19 + _162*71 + _164*58 + _166*36 + _168*92 + _170*78 + _172*31 + _174*68 + _176*84 + _178*80 + _180*81 + _182*5 + _184*24 + _186*95 + _188*52 + _190*88 + _192*79 + _194*56 + _196*87 + _198*54 + _200*37 + _202*16 + _204*97 + _206*1 = 0, - _108*26 + _110*70 + _112*2 + _114*52 + _116*39 + _118*4 + _120*3 + _122*78 + _124*8 + _126*6 + _128*55 + _130*16 + _132*12 + _134*9 + _136*32 + _138*24 + _140*18 + _142*64 + _144*48 + _146*36 + _148*27 + _150*96 + _152*72 + _154*54 + _156*91 + _158*43 + _160*7 + _162*81 + _164*86 + _166*14 + _168*61 + _170*71 + _172*28 + _174*21 + _176*41 + _178*56 + _180*42 + _182*82 + _184*11 + _186*84 + _188*63 + _190*22 + _192*67 + _194*25 + _196*44 + _198*33 + _200*50 + _202*88 + _204*66 + _206*100 = 0, - _108*27 + _110*22 + _112*89 + _114*80 + _116*39 + _118*43 + _120*50 + _122*37 + _124*90 + _126*6 + _128*61 + _130*31 + _132*29 + _134*76 + _136*32 + _138*56 + _140*98 + _142*20 + _144*35 + _146*36 + _148*63 + _150*85 + _152*73 + _154*52 + _156*91 + _158*33 + _160*83 + _162*19 + _164*8 + _166*14 + _168*75 + _170*5 + _172*34 + _174*9 + _176*41 + _178*97 + _180*94 + _182*13 + _184*48 + _186*84 + _188*46 + _190*30 + _192*2 + _194*54 + _196*44 + _198*77 + _200*59 + _202*78 + _204*86 + _206*100 = 0, - _108*28 + _110*77 + _112*35 + _114*71 + _116*69 + _118*13 + _120*61 + _122*92 + _124*51 + _126*14 + _128*89 + _130*68 + _132*86 + _134*85 + _136*57 + _138*81 + _140*46 + _142*76 + _144*7 + _146*95 + _148*34 + _150*43 + _152*93 + _154*79 + _156*91 + _158*23 + _160*38 + _162*54 + _164*98 + _166*17 + _168*72 + _170*97 + _172*90 + _174*96 + _176*62 + _178*19 + _180*27 + _182*49 + _184*59 + _186*36 + _188*99 + _190*45 + _192*48 + _194*31 + _196*60 + _198*64 + _200*75 + _202*80 + _204*18 + _206*100 = 0, - _108*29 + _110*33 + _112*48 + _114*79 + _116*69 + _118*82 + _120*55 + _122*80 + _124*98 + _126*14 + _128*2 + _130*58 + _132*66 + _134*96 + _136*57 + _138*37 + _140*63 + _142*9 + _144*59 + _146*95 + _148*28 + _150*4 + _152*15 + _154*31 + _156*91 + _158*13 + _160*74 + _162*25 + _164*18 + _166*17 + _168*89 + _170*56 + _172*8 + _174*30 + _176*62 + _178*81 + _180*26 + _182*47 + _184*50 + _186*36 + _188*34 + _190*77 + _192*11 + _194*16 + _196*60 + _198*23 + _200*61 + _202*52 + _204*94 + _206*100 = 0, - _108*30 + _110*92 + _112*33 + _114*81 + _116*6 + _118*79 + _120*47 + _122*97 + _124*82 + _126*36 + _128*70 + _130*80 + _132*77 + _134*88 + _136*14 + _138*16 + _140*76 + _142*58 + _144*23 + _146*84 + _148*96 + _150*52 + _152*45 + _154*37 + _156*100 + _158*71 + _160*9 + _162*68 + _164*20 + _166*95 + _168*22 + _170*54 + _172*4 + _174*19 + _176*65 + _178*31 + _180*21 + _182*24 + _184*13 + _186*87 + _188*85 + _190*25 + _192*43 + _194*78 + _196*17 + _198*5 + _200*49 + _202*56 + _204*64 + _206*1 = 0, - _108*31 + _110*52 + _112*97 + _114*78 + _116*95 + _118*16 + _120*92 + _122*24 + _124*37 + _126*36 + _128*5 + _130*54 + _132*58 + _134*81 + _136*87 + _138*71 + _140*80 + _142*56 + _144*19 + _146*84 + _148*79 + _150*25 + _152*68 + _154*88 + _156*1 + _158*31 + _160*52 + _162*97 + _164*78 + _166*95 + _168*16 + _170*92 + _172*24 + _174*37 + _176*36 + _178*5 + _180*54 + _182*58 + _184*81 + _186*87 + _188*71 + _190*80 + _192*56 + _194*19 + _196*84 + _198*79 + _200*25 + _202*68 + _204*88 + _206*1 = 0, - _108*32 + _110*14 + _112*44 + _114*95 + _116*10 + _118*17 + _120*39 + _122*36 + _124*41 + _126*100 + _128*69 + _130*87 + _132*57 + _134*6 + _136*91 + _138*84 + _140*62 + _142*65 + _144*60 + _146*1 + _148*32 + _150*14 + _152*44 + _154*95 + _156*10 + _158*17 + _160*39 + _162*36 + _164*41 + _166*100 + _168*69 + _170*87 + _172*57 + _174*6 + _176*91 + _178*84 + _180*62 + _182*65 + _184*60 + _186*1 + _188*32 + _190*14 + _192*44 + _194*95 + _196*10 + _198*17 + _200*39 + _202*36 + _204*41 + _206*100 = 0, - _108*33 + _110*79 + _112*82 + _114*80 + _116*14 + _118*58 + _120*96 + _122*37 + _124*9 + _126*95 + _128*4 + _130*31 + _132*13 + _134*25 + _136*17 + _138*56 + _140*30 + _142*81 + _144*47 + _146*36 + _148*77 + _150*16 + _152*23 + _154*52 + _156*100 + _158*68 + _160*22 + _162*19 + _164*21 + _166*87 + _168*43 + _170*5 + _172*64 + _174*92 + _176*6 + _178*97 + _180*70 + _182*88 + _184*76 + _186*84 + _188*45 + _190*71 + _192*20 + _194*54 + _196*65 + _198*24 + _200*85 + _202*78 + _204*49 + _206*1 = 0, - _108*34 + _110*45 + _112*15 + _114*5 + _116*69 + _118*23 + _120*75 + _122*25 + _124*42 + _126*14 + _128*72 + _130*24 + _132*8 + _134*70 + _136*57 + _138*19 + _140*40 + _142*47 + _144*83 + _146*95 + _148*99 + _150*33 + _152*11 + _154*71 + _156*91 + _158*64 + _160*55 + _162*52 + _164*51 + _166*17 + _168*73 + _170*58 + _172*53 + _174*85 + _176*62 + _178*88 + _180*63 + _182*21 + _184*7 + _186*36 + _188*12 + _190*4 + _192*35 + _194*79 + _196*60 + _198*20 + _200*74 + _202*92 + _204*98 + _206*100 = 0, - _108*35 + _110*13 + _112*51 + _114*68 + _116*57 + _118*76 + _120*34 + _122*79 + _124*38 + _126*17 + _128*90 + _130*19 + _132*59 + _134*45 + _136*60 + _138*80 + _140*73 + _142*30 + _144*40 + _146*87 + _148*15 + _150*20 + _152*94 + _154*58 + _156*10 + _158*47 + _160*29 + _162*5 + _164*74 + _166*65 + _168*53 + _170*37 + _172*83 + _174*77 + _176*69 + _178*92 + _180*89 + _182*85 + _184*46 + _186*95 + _188*93 + _190*23 + _192*98 + _194*97 + _196*62 + _198*49 + _200*99 + _202*31 + _204*75 + _206*100 = 0, - _108*36 + _110*84 + _112*95 + _114*87 + _116*1 + _118*36 + _120*84 + _122*95 + _124*87 + _126*1 + _128*36 + _130*84 + _132*95 + _134*87 + _136*1 + _138*36 + _140*84 + _142*95 + _144*87 + _146*1 + _148*36 + _150*84 + _152*95 + _154*87 + _156*1 + _158*36 + _160*84 + _162*95 + _164*87 + _166*1 + _168*36 + _170*84 + _172*95 + _174*87 + _176*1 + _178*36 + _180*84 + _182*95 + _184*87 + _186*1 + _188*36 + _190*84 + _192*95 + _194*87 + _196*1 + _198*36 + _200*84 + _202*95 + _204*87 + _206*1 = 0, - _108*37 + _110*56 + _112*52 + _114*5 + _116*84 + _118*78 + _120*58 + _122*25 + _124*16 + _126*87 + _128*88 + _130*24 + _132*80 + _134*31 + _136*36 + _138*19 + _140*97 + _142*54 + _144*79 + _146*95 + _148*81 + _150*68 + _152*92 + _154*71 + _156*1 + _158*37 + _160*56 + _162*52 + _164*5 + _166*84 + _168*78 + _170*58 + _172*25 + _174*16 + _176*87 + _178*88 + _180*24 + _182*80 + _184*31 + _186*36 + _188*19 + _190*97 + _192*54 + _194*79 + _196*95 + _198*81 + _200*68 + _202*92 + _204*71 + _206*1 = 0, - _108*38 + _110*30 + _112*29 + _114*92 + _116*62 + _118*33 + _120*42 + _122*81 + _124*48 + _126*6 + _128*26 + _130*79 + _132*73 + _134*47 + _136*69 + _138*97 + _140*50 + _142*82 + _144*86 + _146*36 + _148*55 + _150*70 + _152*34 + _154*80 + _156*10 + _158*77 + _160*98 + _162*88 + _164*11 + _166*14 + _168*27 + _170*16 + _172*2 + _174*76 + _176*60 + _178*58 + _180*83 + _182*23 + _184*66 + _186*84 + _188*61 + _190*96 + _192*12 + _194*52 + _196*57 + _198*45 + _200*94 + _202*37 + _204*93 + _206*100 = 0, - _108*39 + _110*6 + _112*32 + _114*36 + _116*91 + _118*14 + _120*41 + _122*84 + _124*44 + _126*100 + _128*62 + _130*95 + _132*69 + _134*65 + _136*10 + _138*87 + _140*60 + _142*17 + _144*57 + _146*1 + _148*39 + _150*6 + _152*32 + _154*36 + _156*91 + _158*14 + _160*41 + _162*84 + _164*44 + _166*100 + _168*62 + _170*95 + _172*69 + _174*65 + _176*10 + _178*87 + _180*60 + _182*17 + _184*57 + _186*1 + _188*39 + _190*6 + _192*32 + _194*36 + _196*91 + _198*14 + _200*41 + _202*84 + _204*44 + _206*100 = 0, - _108*40 + _110*85 + _112*67 + _114*54 + _116*39 + _118*45 + _120*83 + _122*88 + _124*86 + _126*6 + _128*38 + _130*5 + _132*99 + _134*21 + _136*32 + _138*68 + _140*94 + _142*23 + _144*11 + _146*36 + _148*26 + _150*30 + _152*89 + _154*25 + _156*91 + _158*4 + _160*59 + _162*37 + _164*66 + _166*14 + _168*55 + _170*79 + _172*29 + _174*49 + _176*41 + _178*24 + _180*51 + _182*20 + _184*93 + _186*84 + _188*27 + _190*70 + _192*73 + _194*92 + _196*44 + _198*43 + _200*3 + _202*19 + _204*53 + _206*100 = 0, - _108*41 + _110*65 + _112*39 + _114*84 + _116*10 + _118*6 + _120*44 + _122*87 + _124*32 + _126*100 + _128*60 + _130*36 + _132*62 + _134*17 + _136*91 + _138*95 + _140*57 + _142*14 + _144*69 + _146*1 + _148*41 + _150*65 + _152*39 + _154*84 + _156*10 + _158*6 + _160*44 + _162*87 + _164*32 + _166*100 + _168*60 + _170*36 + _172*62 + _174*17 + _176*91 + _178*95 + _180*57 + _182*14 + _184*69 + _186*1 + _188*41 + _190*65 + _192*39 + _194*84 + _196*10 + _198*6 + _200*44 + _202*87 + _204*32 + _206*100 = 0, - _108*42 + _110*47 + _112*55 + _114*88 + _116*60 + _118*96 + _120*93 + _122*68 + _124*28 + _126*65 + _128*3 + _130*25 + _132*40 + _134*64 + _136*62 + _138*79 + _140*86 + _142*77 + _144*2 + _146*84 + _148*94 + _150*9 + _152*75 + _154*19 + _156*91 + _158*85 + _160*35 + _162*56 + _164*29 + _166*6 + _168*50 + _170*80 + _172*27 + _174*23 + _176*57 + _178*71 + _180*53 + _182*4 + _184*67 + _186*87 + _188*18 + _190*49 + _192*38 + _194*81 + _196*69 + _198*70 + _200*11 + _202*58 + _204*12 + _206*100 = 0, - _108*43 + _110*31 + _112*20 + _114*52 + _116*14 + _118*97 + _120*30 + _122*78 + _124*21 + _126*95 + _128*45 + _130*16 + _132*82 + _134*92 + _136*17 + _138*24 + _140*22 + _142*37 + _144*76 + _146*36 + _148*33 + _150*5 + _152*13 + _154*54 + _156*100 + _158*58 + _160*70 + _162*81 + _164*49 + _166*87 + _168*4 + _170*71 + _172*23 + _174*80 + _176*6 + _178*56 + _180*85 + _182*19 + _184*9 + _186*84 + _188*77 + _190*79 + _192*64 + _194*25 + _196*65 + _198*68 + _200*96 + _202*88 + _204*47 + _206*1 = 0, - _108*44 + _110*17 + _112*41 + _114*87 + _116*91 + _118*65 + _120*32 + _122*95 + _124*39 + _126*100 + _128*57 + _130*84 + _132*60 + _134*14 + _136*10 + _138*36 + _140*69 + _142*6 + _144*62 + _146*1 + _148*44 + _150*17 + _152*41 + _154*87 + _156*91 + _158*65 + _160*32 + _162*95 + _164*39 + _166*100 + _168*57 + _170*84 + _172*60 + _174*14 + _176*10 + _178*36 + _180*69 + _182*6 + _184*62 + _186*1 + _188*44 + _190*17 + _192*41 + _194*87 + _196*91 + _198*65 + _200*32 + _202*95 + _204*39 + _206*100 = 0, - _108*45 + _110*5 + _112*23 + _114*25 + _116*14 + _118*24 + _120*70 + _122*19 + _124*47 + _126*95 + _128*33 + _130*71 + _132*64 + _134*52 + _136*17 + _138*58 + _140*85 + _142*88 + _144*21 + _146*36 + _148*4 + _150*79 + _152*20 + _154*92 + _156*100 + _158*56 + _160*96 + _162*78 + _164*76 + _166*87 + _168*77 + _170*31 + _172*82 + _174*54 + _176*6 + _178*68 + _180*30 + _182*37 + _184*49 + _186*84 + _188*43 + _190*16 + _192*13 + _194*80 + _196*65 + _198*97 + _200*22 + _202*81 + _204*9 + _206*1 = 0, - _108*46 + _110*96 + _112*73 + _114*25 + _116*39 + _118*77 + _120*7 + _122*19 + _124*66 + _126*6 + _128*74 + _130*71 + _132*34 + _134*49 + _136*32 + _138*58 + _140*42 + _142*13 + _144*93 + _146*36 + _148*40 + _150*22 + _152*2 + _154*92 + _156*91 + _158*45 + _160*50 + _162*78 + _164*53 + _166*14 + _168*38 + _170*31 + _172*12 + _174*47 + _176*41 + _178*68 + _180*98 + _182*64 + _184*15 + _186*84 + _188*26 + _190*85 + _192*72 + _194*80 + _196*44 + _198*4 + _200*83 + _202*81 + _204*90 + _206*100 = 0, - _108*47 + _110*88 + _112*96 + _114*68 + _116*65 + _118*25 + _120*64 + _122*79 + _124*77 + _126*84 + _128*9 + _130*19 + _132*85 + _134*56 + _136*6 + _138*80 + _140*23 + _142*71 + _144*4 + _146*87 + _148*49 + _150*81 + _152*70 + _154*58 + _156*100 + _158*54 + _160*13 + _162*5 + _164*33 + _166*36 + _168*76 + _170*37 + _172*22 + _174*24 + _176*17 + _178*92 + _180*82 + _182*16 + _184*45 + _186*95 + _188*21 + _190*78 + _192*30 + _194*97 + _196*14 + _198*52 + _200*20 + _202*31 + _204*43 + _206*1 = 0, - _108*48 + _110*82 + _112*98 + _114*58 + _116*57 + _118*9 + _120*28 + _122*31 + _124*74 + _126*17 + _128*8 + _130*81 + _132*50 + _134*77 + _136*60 + _138*52 + _140*72 + _142*22 + _144*46 + _146*87 + _148*35 + _150*64 + _152*42 + _154*97 + _156*10 + _158*76 + _160*12 + _162*71 + _164*75 + _166*65 + _168*90 + _170*78 + _172*7 + _174*33 + _176*69 + _178*80 + _180*2 + _182*96 + _184*63 + _186*95 + _188*15 + _190*13 + _192*18 + _194*56 + _196*62 + _198*47 + _200*34 + _202*16 + _204*61 + _206*100 = 0, - _108*49 + _110*78 + _112*85 + _114*24 + _116*65 + _118*54 + _120*20 + _122*71 + _124*45 + _126*84 + _128*76 + _130*88 + _132*70 + _134*97 + _136*6 + _138*92 + _140*64 + _142*5 + _144*43 + _146*87 + _148*21 + _150*19 + _152*22 + _154*68 + _156*100 + _158*52 + _160*23 + _162*16 + _164*77 + _166*36 + _168*47 + _170*81 + _172*30 + _174*56 + _176*17 + _178*25 + _180*13 + _182*31 + _184*4 + _186*95 + _188*9 + _190*37 + _192*96 + _194*58 + _196*14 + _198*80 + _200*82 + _202*79 + _204*33 + _206*1 = 0, - _108*50 + _110*76 + _112*63 + _114*19 + _116*41 + _118*30 + _120*86 + _122*58 + _124*72 + _126*65 + _128*18 + _130*92 + _132*55 + _134*23 + _136*39 + _138*31 + _140*35 + _142*33 + _144*34 + _146*84 + _148*59 + _150*21 + _152*40 + _154*81 + _156*10 + _158*96 + _160*53 + _162*24 + _164*89 + _166*6 + _168*98 + _170*52 + _172*75 + _174*13 + _176*44 + _178*79 + _180*11 + _182*45 + _184*28 + _186*87 + _188*7 + _190*47 + _192*27 + _194*37 + _196*32 + _198*85 + _200*8 + _202*97 + _204*2 + _206*100 = 0 - }. - diff --git a/CLPQR/clpqr/examples/eliminat.pl b/CLPQR/clpqr/examples/eliminat.pl deleted file mode 100644 index 9cc51752b..000000000 --- a/CLPQR/clpqr/examples/eliminat.pl +++ /dev/null @@ -1,315 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: eliminat.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -/* - - If you want to learn more about the subject of quantifier elimination - you should read: - - Huynh T., Lassez J.L.: Practical Issues on the Projection of Polyhedral Sets, - IBM Research Division, RC 15872 (#70560), 1990. - - - The predicate example/1 below relates the four variables X1,X2,X3,X4 - in some way. The query 'example( [X1,X2,X3,X4])' just returns the - normalized set of constraints (there is no redundancy). - Now suppose you want to know: what are the implied relations - between X3 and X4? The following query expresses this projection: - - [Clp(Q)] ?- example( 1, [_,_,X3,X4]). - - X4=<1+3*X3, - X4=<4/13+18/13*X3, - X4>=-1/8+9/8*X3, - X4>= -2+6*X3, - X4>=-1/11+9/11*X3 - -*/ - -% -% taken from the reference above -% -example( 1, [X1,X2,X3,X4]) :- - { - 12*X1 + X2 - 3*X3 + X4 =< 1, - -36*X1 - 2*X2 + 18*X3 - 11*X4 =< -2, - -18*X1 - X2 + 9*X3 - 7*X4 =< -1, - 45*X1 + 4*X2 - 18*X3 + 13*X4 =< 4, - X1 >= 0, - X2 >= 0 - }. - -example( 2, [X0,X1,X2,X3,X4]) :- - { % supremum for the row - +87*X0 +52*X1 +27*X2 -54*X3 +56*X4 =< -93, % r -1108 - +33*X0 -10*X1 +61*X2 -28*X3 -29*X4 =< 63, % r - 595 - -68*X0 +8*X1 +35*X2 +68*X3 +35*X4 =< -85, % - 85 - +90*X0 +60*X1 -76*X2 -53*X3 +24*X4 =< -68, % - 68 - -95*X0 -10*X1 +64*X2 +76*X3 -24*X4 =< 33, % 33 - +43*X0 -22*X1 +67*X2 -68*X3 -92*X4 =< -97, % r - 709 - +39*X0 +7*X1 +62*X2 +54*X3 -26*X4 =< -27, % - 27 - +48*X0 -13*X1 +7*X2 -61*X3 -59*X4 =< -2, % r - 211 - +49*X0 -23*X1 -31*X2 -76*X3 +27*X4 =< 3, % 3 - -50*X0 +58*X1 -1*X2 +57*X3 +20*X4 =< 6, % 6 - -13*X0 -63*X1 +81*X2 -3*X3 +70*X4 =< 64, % r - 385 - +20*X0 +67*X1 -23*X2 -41*X3 -66*X4 =< 52, % r - 489 - -81*X0 -44*X1 +19*X2 -22*X3 -73*X4 =< -17, % - 17 - -43*X0 -9*X1 +14*X2 +27*X3 +40*X4 =< 39, % 39 - +16*X0 +83*X1 +89*X2 +25*X3 +55*X4 =< 36, % r -1474 - +2*X0 +40*X1 +65*X2 +59*X3 -32*X4 =< 13, % r - 378 - -65*X0 -11*X1 +10*X2 -13*X3 +91*X4 =< 49, % r - 366 - +93*X0 -73*X1 +91*X2 -1*X3 +23*X4 =< -87 % - 87 - }. - -example( 3, [X1,X2,X3,X4]) :- - { - 12*X1 + X2 - 3*X3 + X4 =< 1, - -36*X1 - 2*X2 + 18*X3 - 11*X4 =< -2, - -18*X1 - X2 + 9*X3 - 7*X4 =< -1, - 45*X1 + 4*X2 - 18*X3 + 13*X4 =< 4, - X1 > 0, % strict !!! - X2 >= 0 - }. - - - - -/* - - The next example deals with the computation of the convex hull of - a given set of points. The problem can be formulated as a quantifier - elimination problem (for details please refer to the reference). - - Example: - - The set of three points in a 3 dimensional space is represented as - - [ [1,0,0], [0,1,0], [0,0,1] ] - - The following query computes the convex hull. - - [Clp(Q)] ?- conv_hull( [ [1,0,0],[0,1,0],[0,0,1] ], [X1,X2,X3] ). - - X3 = 1-X1-X2, - X1=<1-X2, - X2>=0, - X1>=0 - - In two dimensions it is easier to visualize and verify the - result: - - | - 2 - * * - | - | - 1 - * - | - | - 0 -----|----*----*---- - 1 2 3 - - [Clp(Q)] ?- conv_hull([ [1,1], [2,0], [3,0], [1,2], [2,2] ], [X,Y]). - - X=<3-1/2*Y, - Y=<2, - Y>=0, - X>=1, - X>=2-Y - -*/ - -hull( [X,Y]) :- conv_hull([ [1,1], [2,0], [3,0], [1,2], [2,2] ], [X,Y]). - -conv_hull( Points, Xs) :- - lin_comb( Points, Lambdas, Zero, Xs), - zero( Zero), - polytope( Lambdas). - -polytope( Xs) :- - positive_sum( Xs, 1). - - positive_sum( [], Z) :- {Z=0}. - positive_sum( [X|Xs], SumX) :- - { X >= 0, SumX = X+Sum }, - positive_sum( Xs, Sum). - -zero( []). -zero( [Z|Zs]) :- {Z=0}, zero( Zs). - -lin_comb( [], [], S1, S1). -lin_comb( [Ps|Rest], [K|Ks], S1, S3) :- - lin_comb_r( Ps, K, S1, S2), - lin_comb( Rest, Ks, S2, S3). - - lin_comb_r( [], _, [], []). - lin_comb_r( [P|Ps], K, [S|Ss], [Kps|Ss1]) :- - { Kps = K*P+S }, - lin_comb_r( Ps, K, Ss, Ss1). - -% -------------------------------- junkyard -------------------------------- - -/* -subseq0(List, List). -subseq0(List, Rest) :- - subseq1(List, Rest). - -subseq1([_Head|Tail], Rest) :- - subseq0(Tail, Rest). -subseq1([ Head|Tail], [Head|Rest]) :- - subseq1(Tail, Rest). - -subseq0([A,B,C,D,E],S),portray_clause((proj(2,S):-example(2,[A,B,C,D,E]))),fail. -*/ - -proj( N) :- - time( call_residue( proj(N,P), R)), - numbervars(P,0,_), - length( R, Rl), - print(P:Rl),nl,presi(R),nl, - fail. - -presi( []). -presi( [_-R|Rs]) :- - print( R), nl, - presi( Rs). - -proj(1, [A,B,C,D]) :- - example(1, [A,B,C,D]). -proj(1, [A,B,C]) :- - example(1, [_,A,B,C]). -proj(1, [A,B]) :- - example(1, [_,_,A,B]). -proj(1, [A]) :- - example(1, [_,_,_,A]). -proj(1, []) :- - example(1, [_,_,_,_]). -proj(1, [A]) :- - example(1, [_,_,A,_]). -proj(1, [A,B]) :- - example(1, [_,A,_,B]). -proj(1, [A]) :- - example(1, [_,A,_,_]). -proj(1, [A,B]) :- - example(1, [_,A,B,_]). -proj(1, [A,B,C]) :- - example(1, [A,_,B,C]). -proj(1, [A,B]) :- - example(1, [A,_,_,B]). -proj(1, [A]) :- - example(1, [A,_,_,_]). -proj(1, [A,B]) :- - example(1, [A,_,B,_]). -proj(1, [A,B,C]) :- - example(1, [A,B,_,C]). -proj(1, [A,B]) :- - example(1, [A,B,_,_]). -proj(1, [A,B,C]) :- - example(1, [A,B,C,_]). - -proj(2, [A,B,C,D,E]) :- - example(2, [A,B,C,D,E]). -proj(2, [A,B,C,D]) :- - example(2, [_,A,B,C,D]). -proj(2, [A,B,C]) :- - example(2, [_,_,A,B,C]). -proj(2, [A,B]) :- - example(2, [_,_,_,A,B]). -proj(2, [A]) :- - example(2, [_,_,_,_,A]). -proj(2, []) :- - example(2, [_,_,_,_,_]). -proj(2, [A]) :- - example(2, [_,_,_,A,_]). -proj(2, [A,B]) :- - example(2, [_,_,A,_,B]). -proj(2, [A]) :- - example(2, [_,_,A,_,_]). -proj(2, [A,B]) :- - example(2, [_,_,A,B,_]). -proj(2, [A,B,C]) :- - example(2, [_,A,_,B,C]). -proj(2, [A,B]) :- - example(2, [_,A,_,_,B]). -proj(2, [A]) :- - example(2, [_,A,_,_,_]). -proj(2, [A,B]) :- - example(2, [_,A,_,B,_]). -proj(2, [A,B,C]) :- - example(2, [_,A,B,_,C]). -proj(2, [A,B]) :- - example(2, [_,A,B,_,_]). -proj(2, [A,B,C]) :- - example(2, [_,A,B,C,_]). -proj(2, [A,B,C,D]) :- - example(2, [A,_,B,C,D]). -proj(2, [A,B,C]) :- - example(2, [A,_,_,B,C]). -proj(2, [A,B]) :- - example(2, [A,_,_,_,B]). -proj(2, [A]) :- - example(2, [A,_,_,_,_]). -proj(2, [A,B]) :- - example(2, [A,_,_,B,_]). -proj(2, [A,B,C]) :- - example(2, [A,_,B,_,C]). -proj(2, [A,B]) :- - example(2, [A,_,B,_,_]). -proj(2, [A,B,C]) :- - example(2, [A,_,B,C,_]). -proj(2, [A,B,C,D]) :- - example(2, [A,B,_,C,D]). -proj(2, [A,B,C]) :- - example(2, [A,B,_,_,C]). -proj(2, [A,B]) :- - example(2, [A,B,_,_,_]). -proj(2, [A,B,C]) :- - example(2, [A,B,_,C,_]). -proj(2, [A,B,C,D]) :- - example(2, [A,B,C,_,D]). -proj(2, [A,B,C]) :- - example(2, [A,B,C,_,_]). -proj(2, [A,B,C,D]) :- - example(2, [A,B,C,D,_]). - -proj(3, [A,B,C,D]) :- - example(3, [A,B,C,D]). -proj(3, [A,B,C]) :- - example(3, [_,A,B,C]). -proj(3, [A,B]) :- - example(3, [_,_,A,B]). -proj(3, [A]) :- - example(3, [_,_,_,A]). -proj(3, []) :- - example(3, [_,_,_,_]). -proj(3, [A]) :- - example(3, [_,_,A,_]). -proj(3, [A,B]) :- - example(3, [_,A,_,B]). -proj(3, [A]) :- - example(3, [_,A,_,_]). -proj(3, [A,B]) :- - example(3, [_,A,B,_]). -proj(3, [A,B,C]) :- - example(3, [A,_,B,C]). -proj(3, [A,B]) :- - example(3, [A,_,_,B]). -proj(3, [A]) :- - example(3, [A,_,_,_]). -proj(3, [A,B]) :- - example(3, [A,_,B,_]). -proj(3, [A,B,C]) :- - example(3, [A,B,_,C]). -proj(3, [A,B]) :- - example(3, [A,B,_,_]). -proj(3, [A,B,C]) :- - example(3, [A,B,C,_]). diff --git a/CLPQR/clpqr/examples/matmul.pl b/CLPQR/clpqr/examples/matmul.pl deleted file mode 100644 index a85be9362..000000000 --- a/CLPQR/clpqr/examples/matmul.pl +++ /dev/null @@ -1,89 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: matmul.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -matmul( [], _, []). -matmul( [H|T], B, [H1|T1]) :- - rowmul( B, H, H1), - matmul( T, B, T1). - -rowmul( [], _, []). -rowmul( [H|T], AV, [H1|T1]) :- - vecmul( AV, H, 0, H1), - rowmul( T, AV, T1). - -/* -% -% eager -% -vecmul( [], [], S, S). -vecmul( [H1|T1], [H2|T2], In, Out) :- - { Sofar=In+H1*H2 }, - vecmul( T1, T2, Sofar, Out). -*/ - -% -% lazy -% -vecmul( [], [], S0, S1) :- { S0=S1 }. -vecmul( [H1|T1], [H2|T2], In, Out) :- - vecmul( T1, T2, In+H1*H2, Out). - -inv_hilbert( N) :- - hilbert( N, H), - identity( N, U), - statistics( runtime, _), - matmul( H, Inv, U), - statistics( runtime, [_,Lp_time]), - format( "% took ~p msec~n", [Lp_time]), - printnl( Inv). - -printnl( []). -printnl( [H|T]) :- print( H), nl, printnl( T). - -% ---------- simple matrix generator - -mat( I, N, _, []) :- I > N, !. -mat( I, N, Fn, [Row|Rows]) :- - mat_row( I, 1, N, Fn, Row), - I1 is I+1, - mat( I1, N, Fn, Rows). - -mat_row( _, J, N, _, []) :- J > N, !. -mat_row( I, J, N, Fn, [Res|Es]) :- - Call =.. [Fn,I,J,Res], - call( Call), - J1 is J+1, - mat_row( I, J1, N, Fn, Es). - -identity( N, Mat) :- - mat( 1, N, ident, Mat). - -ident( I, I, 1) :- !. -ident( _, _, 0). - -caneghem( N, Mat) :- - mat( 1, N, can, Mat). - -can( I, J, El) :- can( I, J, 1, 101, El). - -can( I, 1, Curr, Mod, El) :- !, El is (I*Curr) mod Mod. -can( I, J, Curr, Mod, El) :- - J1 is J-1, - C1 is (Curr*I) mod Mod, - can( I, J1, C1, Mod, El). - -hilbert( N, Mat) :- - mat( 1, N, hilbert, Mat). - -hilbert( I, J, 1/X) :- X is I+J-1. - diff --git a/CLPQR/clpqr/examples/mg.pl b/CLPQR/clpqr/examples/mg.pl deleted file mode 100644 index e05be239c..000000000 --- a/CLPQR/clpqr/examples/mg.pl +++ /dev/null @@ -1,25 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: mg.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -mg(P,T,I,B,MP) :- - { - T = 1, - B + MP = P * (1 + I) - }. -mg(P,T,I,B,MP) :- - { - T > 1, - P1 = P * (1 + I) - MP, - T1 = T - 1 - }, - mg(P1, T1, I, B, MP). diff --git a/CLPQR/clpqr/examples/mip.pl b/CLPQR/clpqr/examples/mip.pl deleted file mode 100644 index 62b129322..000000000 --- a/CLPQR/clpqr/examples/mip.pl +++ /dev/null @@ -1,1826 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: mip.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -example( N) :- - example( N, O, _, I, _), - statistics( runtime, _), - bb_inf( I, O, Inf, _, 0.001), - print( N:Inf), nl, - statistics( runtime, [_,T]), - print_time( T). - -print_time( T) :- print_time( '%%% Timing', T). - -% -% milliseconds -% -print_time( What, T) :- - Seconds is T/1000, - Hour is T // 3600000, - R0 is T-Hour*3600000, - Min is R0 // 60000, - R1 is R0-Min*60000, - Sec is R1/1000, - format( "~|~w~t~15+ ~|~`0t~d~2+:~|~`0t~d~2+:~|~`0t~3f~6+ ~t~3f~10+~n", - [What,Hour,Min,Sec,Seconds]). - - -% -% s20196, pp.427, Opt = 13, X1=2,X2=1 -% -example( 1, Obj, Vs, Vs, []) :- - Vs = [X1,X2], - { - 3*X1 + X2 >= 2, - X1 + 4*X2 >= 5, - 3*X1 + 2*X2 >= 7, - X1 >= 0, - X2 >= 0 - }, - attach_name( X1, x1), - attach_name( X2, x2), - Obj = 4*X1 + 5*X2. - -% -% s22738, pp.303 -% -example( 2, Obj, Vs, [X1,X2], []) :- - Vs = [X1,X2,X3], - { - 3*X1 + 7*X2 + 3*X3 =< 14, - 9*X1 + 5*X2 + 3*X3 =< 37, - X1 >= 0, - X2 >= 0, - X3 >= 0 - }, - attach_name( X1, x1), - attach_name( X2, x2), - attach_name( X3, x3), - Obj = 32*X1 - 21*X2 + 12*X3. - -% -% translated examples from miplib -% - -% -% example( Name, Obj, Opt, Allvars, Integer, Bool) -% - -% - % imin( [Stm2, Stm5, Anm1, Anm4, Stm4, Anm3, Anm6, Stm3, Stm6, Anm2, Anm5], Obj). - % - % same integerization ordering as in lp_solve - % - % imin( [Stm6, Stm5, Stm4, Stm3, Stm2, Anm6, Anm5, Anm4, Anm3, Anm2, Anm1], Obj). -% -example( flugpl, Obj, Vs, Ints, []) :- - - Vs = [ Anm1,Anm2,Anm3,Anm4,Anm5,Anm6, - Stm1,Stm2,Stm3,Stm4,Stm5,Stm6, - UE1,UE2,UE3,UE4,UE5,UE6 - ], - - Ints = [Stm6, Stm5, Stm4, Stm3, Stm2, Anm6, Anm5, Anm4, Anm3, Anm2, Anm1], - - Obj = +2700*Stm1 +1500*Anm1 +30*UE1 - +2700*Stm2 +1500*Anm2 +30*UE2 - +2700*Stm3 +1500*Anm3 +30*UE3 - +2700*Stm4 +1500*Anm4 +30*UE4 - +2700*Stm5 +1500*Anm5 +30*UE5 - +2700*Stm6 +1500*Anm6 +30*UE6, - - attach_name( Stm2, stm2), - attach_name( Stm5, stm5), - attach_name( Anm1, anm1), - attach_name( Anm4, anm4), - attach_name( Stm4, stm4), - attach_name( Anm3, anm3), - attach_name( Anm6, anm6), - attach_name( Stm3, stm3), - attach_name( Stm6, stm6), - attach_name( Anm2, anm2), - attach_name( Anm5, anm5), - - allpos( Vs), - { - +1*Stm1 = 60, - +0.9*Stm1 +1*Anm1 -1*Stm2 = 0, - +0.9*Stm2 +1*Anm2 -1*Stm3 = 0, - +0.9*Stm3 +1*Anm3 -1*Stm4 = 0, - +0.9*Stm4 +1*Anm4 -1*Stm5 = 0, - +0.9*Stm5 +1*Anm5 -1*Stm6 = 0, - +150*Stm1 -100*Anm1 +1*UE1 >= 8000, - +150*Stm2 -100*Anm2 +1*UE2 >= 9000, - +150*Stm3 -100*Anm3 +1*UE3 >= 8000, - +150*Stm4 -100*Anm4 +1*UE4 >= 10000, - +150*Stm5 -100*Anm5 +1*UE5 >= 9000, - +150*Stm6 -100*Anm6 +1*UE6 >= 12000, - -20*Stm1 +1*UE1 =< 0, - -20*Stm2 +1*UE2 =< 0, - -20*Stm3 +1*UE3 =< 0, - -20*Stm4 +1*UE4 =< 0, - -20*Stm5 +1*UE5 =< 0, - -20*Stm6 +1*UE6 =< 0, - Anm1 =< 18, - 57 =< Stm2, - Stm2 =< 75, - Anm2 =< 18, - 57 =< Stm3, - Stm3 =< 75, - Anm3 =< 18, - 57 =< Stm4, - Stm4 =< 75, - Anm4 =< 18, - 57 =< Stm5, - Stm5 =< 75, - Anm5 =< 18, - 57 =< Stm6, - Stm6 =< 75, - Anm6 =< 18 - }. - -% -% Do not edit this file! It was produced automatically by mps2prolog. -% -% NAME: flugpl -% ROWS: 18 -% COLUMNS: 18 -% INTEGER: 11 -% NONZERO: 46 -% BEST SOLN: 1201500 (opt) -% LP SOLN: 1167185.73 -% SOURCE: Harvey M. Wagner -% John W. Gregory (Cray Research) -% E. Andrew Boyd (Rice University) -% APPLICATION: airline model -% COMMENTS: no integer variables are binary -% -% -% -example( flugplan, Min, Vs, Ints, Bins) :- - Vs = [X1, X10, X11, X12, X13, X14, X15, X16, X17, X18, X2, X3, X4, - X5, X6, X7, X8, X9], - Ints = [X10, X11, X13, X14, X16, X17, X2, X4, X5, X7, X8], - Bins = [], - Min = +2700*X1 +1500*X2 +30*X3 +2700*X4 +1500*X5 +30*X6 +2700*X7 - +1500*X8 +30*X9 +2700*X10 +1500*X11 +30*X12 +2700*X13 +1500*X14 - +30*X15 +2700*X16 +1500*X17 +30*X18, - { - 0 =< X1, - 57 =< X10, X10 =< 75, - 0 =< X11, X11 =< 18, - 0 =< X12, - 57 =< X13, X13 =< 75, - 0 =< X14, X14 =< 18, - 0 =< X15, - 57 =< X16, X16 =< 75, - 0 =< X17, X17 =< 18, - 0 =< X18, - 0 =< X2, X2 =< 18, - 0 =< X3, - 57 =< X4, X4 =< 75, - 0 =< X5, X5 =< 18, - 0 =< X6, - 57 =< X7, X7 =< 75, - 0 =< X8, X8 =< 18, - 0 =< X9, - -20*X1 +X3 =< 0, - -20*X10 +X12 =< 0, - +0.9*X4 +X5 -X7 = 0, - +150*X1 -100*X2 +X3 >= 8000, - +0.9*X13 +X14 -X16 = 0, - +150*X10 -100*X11 +X12 >= 10000, - -20*X7 +X9 =< 0, - +0.9*X1 +X2 -X4 = 0, - -20*X16 +X18 =< 0, - +0.9*X10 +X11 -X13 = 0, - +150*X7 -100*X8 +X9 >= 8000, - +150*X16 -100*X17 +X18 >= 12000, - -20*X4 +X6 =< 0, - +X1 = 60, - -20*X13 +X15 =< 0, - +0.9*X7 +X8 -X10 = 0, - +150*X4 -100*X5 +X6 >= 9000, - +150*X13 -100*X14 +X15 >= 9000 - }, - attach_name(X2,'ANM1'), - attach_name(X5,'ANM2'), - attach_name(X8,'ANM3'), - attach_name(X11,'ANM4'), - attach_name(X14,'ANM5'), - attach_name(X17,'ANM6'), - attach_name(X1,'STM1'), - attach_name(X4,'STM2'), - attach_name(X7,'STM3'), - attach_name(X10,'STM4'), - attach_name(X13,'STM5'), - attach_name(X16,'STM6'), - attach_name(X3,'UE1'), - attach_name(X6,'UE2'), - attach_name(X9,'UE3'), - attach_name(X12,'UE4'), - attach_name(X15,'UE5'), - attach_name(X18,'UE6'), - true. - - -% -% Do not edit this file! It was produced automatically by mps2prolog. -% -% NAME: stein15 -% ROWS: 36 -% COLUMNS: 15 -% INTEGER: 15 -% NONZERO: 120 -% BEST SOLN: 9 (opt) -% LP SOLN: 7.0 -% SOURCE: George L. Nemhauser (Georgia Institute of Technology) -% John W. Gregory (Cray Research) -% E. Andrew Boyd (Rice University) -% APPLICATION: unknown -% COMMENTS: pure 0/1 IP -% -% lp_solve Integerization strategy: -% v0009, v0008, v0015, v0007, v0014, v0006, v0013, v0005, v0012, -% v0004, v0011, v0003, v0010, v0002, v0001 -% -% -example( stein15, Min, Vs, Ints, Bins) :- - Vs = [X1, X10, X11, X12, X13, X14, X15, X2, X3, X4, X5, X6, X7, X8, - X9], -% Ints = [X1, X10, X11, X12, X13, X14, X15, X2, X3, X4, X5, X6, X7, X8, X9], - Ints = [X9, X8, X15, X7, X14, X6, X13, X5, X12, X4, X11, X3, X10, X2, X1], - Bins = [], - Min = +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 +X9 +X10 +X11 +X12 +X13 +X14 - +X15, - { - 0 =< X1, X1 =< 1, - 0 =< X10, X10 =< 1, - 0 =< X11, X11 =< 1, - 0 =< X12, X12 =< 1, - 0 =< X13, X13 =< 1, - 0 =< X14, X14 =< 1, - 0 =< X15, X15 =< 1, - 0 =< X2, X2 =< 1, - 0 =< X3, X3 =< 1, - 0 =< X4, X4 =< 1, - 0 =< X5, X5 =< 1, - 0 =< X6, X6 =< 1, - 0 =< X7, X7 =< 1, - 0 =< X8, X8 =< 1, - 0 =< X9, X9 =< 1, - +X7 +X10 +X11 >= 1, - +X1 +X12 +X15 >= 1, - +X2 +X3 +X10 >= 1, - +X6 +X8 +X12 >= 1, - +X1 +X4 +X10 >= 1, - +X2 +X11 +X13 >= 1, - +X6 +X9 +X15 >= 1, - +X1 +X2 +X3 +X4 +X5 +X6 +X7 +X8 +X9 +X10 +X11 +X12 +X13 +X14 +X15 - >= 7, - +X5 +X11 +X14 >= 1, - +X4 +X5 +X7 >= 1, - +X7 +X9 +X13 >= 1, - +X8 +X9 +X11 >= 1, - +X1 +X3 +X7 >= 1, - +X3 +X12 +X14 >= 1, - +X1 +X13 +X14 >= 1, - +X1 +X6 +X11 >= 1, - +X8 +X10 +X14 >= 1, - +X9 +X10 +X12 >= 1, - +X4 +X13 +X15 >= 1, - +X1 +X2 +X9 >= 1, - +X2 +X14 +X15 >= 1, - +X2 +X7 +X12 >= 1, - +X3 +X5 +X9 >= 1, - +X6 +X10 +X13 >= 1, - +X3 +X11 +X15 >= 1, - +X3 +X4 +X6 >= 1, - +X3 +X8 +X13 >= 1, - +X2 +X5 +X6 >= 1, - +X6 +X7 +X14 >= 1, - +X4 +X11 +X12 >= 1, - +X4 +X9 +X14 >= 1, - +X7 +X8 +X15 >= 1, - +X1 +X5 +X8 >= 1, - +X5 +X12 +X13 >= 1, - +X2 +X4 +X8 >= 1, - +X5 +X10 +X15 >= 1 - }, - attach_name(X1,'0001'), - attach_name(X2,'0002'), - attach_name(X3,'0003'), - attach_name(X4,'0004'), - attach_name(X5,'0005'), - attach_name(X6,'0006'), - attach_name(X7,'0007'), - attach_name(X8,'0008'), - attach_name(X9,'0009'), - attach_name(X10,'0010'), - attach_name(X11,'0011'), - attach_name(X12,'0012'), - attach_name(X13,'0013'), - attach_name(X14,'0014'), - attach_name(X15,'0015'), - true. - -% -% Do not edit this file! It was produced automatically by mps2prolog. -% -% NAME: sample2 -% ROWS: 45 -% COLUMNS: 67 -% INTEGER: 21 -% NONZERO: 146 -% BEST SOLN: 375 (opt) -% LP SOLN: 247.0 -% SOURCE: -% Laurence A. Wolsey (University of Louvain) -% Martin W. P. Savelsbergh (Eindhoven Univ. of Technology) -% APPLICATION: unknown -% COMMENTS: all integer variables are binary -% -% -% lp_solve Integerization strategy: -% I.W03W03, I.W02W02, I.W01W01, I.D04C03, I.D04C02, I.D04C01, I.D03D03, -% I.D03C03, I.D03C02, I.D03C01, I.D02D02, I.D02C03, I.D02C02, I.D02C01, -% I.D01D01, I.D01C03, I.D01C02, I.D01C01, I....F03, I....F02, I....F01 -% -% -example( sample2, Min, Vs, Ints, Bins) :- - Vs = [X1, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19, X2, X20, - X21, X22, X23, X24, X25, X26, X27, X28, X29, X3, X30, X31, X32, X33, - X34, X35, X36, X37, X38, X39, X4, X40, X41, X42, X43, X44, X45, X46, - X47, X48, X49, X5, X50, X51, X52, X53, X54, X55, X56, X57, X58, X59, - X6, X60, X61, X62, X63, X64, X65, X66, X67, X7, X8, X9], - Ints = [X6, X5, X4, X21, X20, X19, X9, X18, X17, X16, X8, X15, X14, X13, X7, - X12, X11, X10, X3, X2, X1], - Bins = [], - Min = +100*X1 +100*X2 +100*X3 +60*X4 +60*X5 +60*X6 +40*X7 +40*X8 - +40*X9 +X25 +2*X26 +X29 +2*X30 +2*X31 +X33 +2*X38 +4*X39 +6*X40 - +6*X41 +2*X43 +4*X44 +4*X45 +6*X46 +2*X48 +X53 +3*X55 +X56 +3*X57 - +3*X59 +X61 +3*X62 +3*X63 +3*X64, - { - X66 = 15, - X67 = 15, - X65 = 15, - 0 =< X1, X1 =< 1, - 0 =< X10, X10 =< 1, - 0 =< X11, X11 =< 1, - 0 =< X12, X12 =< 1, - 0 =< X13, X13 =< 1, - 0 =< X14, X14 =< 1, - 0 =< X15, X15 =< 1, - 0 =< X16, X16 =< 1, - 0 =< X17, X17 =< 1, - 0 =< X18, X18 =< 1, - 0 =< X19, X19 =< 1, - 0 =< X2, X2 =< 1, - 0 =< X20, X20 =< 1, - 0 =< X21, X21 =< 1, - 0 =< X22, - 0 =< X23, - 0 =< X24, - 0 =< X25, - 0 =< X26, - 0 =< X27, - 0 =< X28, - 0 =< X29, - 0 =< X3, X3 =< 1, - 0 =< X30, - 0 =< X31, - 0 =< X32, - 0 =< X33, - 0 =< X34, - 0 =< X35, - 0 =< X36, - 0 =< X37, - 0 =< X38, - 0 =< X39, - 0 =< X4, X4 =< 1, - 0 =< X40, - 0 =< X41, - 0 =< X42, - 0 =< X43, - 0 =< X44, - 0 =< X45, - 0 =< X46, - 0 =< X47, - 0 =< X48, - 0 =< X49, - 0 =< X5, X5 =< 1, - 0 =< X50, - 0 =< X51, - 0 =< X52, X52 =< 25, - 0 =< X53, - 0 =< X54, - 0 =< X55, - 0 =< X56, - 0 =< X57, - 0 =< X58, - 0 =< X59, - 0 =< X6, X6 =< 1, - 0 =< X60, - 0 =< X61, - 0 =< X62, - 0 =< X63, - 0 =< X64, - 0 =< X65, - 0 =< X66, - 0 =< X67, - 0 =< X7, X7 =< 1, - 0 =< X8, X8 =< 1, - 0 =< X9, X9 =< 1, - -X51 +X59 +X60 +X61 = 0, - -45*X16 +X59 =< 0, - -45*X14 +X57 =< 0, - -45*X12 +X55 =< 0, - -45*X6 +X36 =< 0, - -X53 -X56 -X59 -X62 +X65 = 0, - -X37 -X41 -X45 +X49 = 0, - -X49 +X53 +X54 +X55 = 0, - +X22 +X23 +X24 -X65 -X66 -X67 = 0, - -45*X13 +X56 =< 0, - -45*X11 +X54 =< 0, - +X11 +X14 +X17 +X20 =< 1, - -25*X8 +X50 =< 0, - -X26 -X29 -X32 +X35 = 0, - -X23 +X28 +X29 +X30 = 0, - -X35 +X41 +X42 +X43 +X44 = 0, - -X40 -X44 -X48 +X52 = 0, - -45*X10 +X53 =< 0, - -45*X3 +X24 =< 0, - -X54 -X57 -X60 -X63 +X66 = 0, - -X52 +X62 +X63 +X64 = 0, - -45*X5 +X35 =< 0, - +X10 +X13 +X16 +X19 =< 1, - -X38 -X42 -X46 +X50 = 0, - -45*X2 +X23 =< 0, - -25*X7 +X49 =< 0, - -X24 +X31 +X32 +X33 = 0, - -X50 +X56 +X57 +X58 = 0, - -45*X21 +X64 =< 0, - -X27 -X30 -X33 +X36 = 0, - -X55 -X58 -X61 -X64 +X67 = 0, - -45*X1 +X22 =< 0, - -X36 +X45 +X46 +X47 +X48 = 0, - -45*X4 +X34 =< 0, - -45*X18 +X61 =< 0, - -45*X20 +X63 =< 0, - -X25 -X28 -X31 +X34 = 0, - -X34 +X37 +X38 +X39 +X40 = 0, - -25*X9 +X51 =< 0, - -45*X15 +X58 =< 0, - -45*X17 +X60 =< 0, - -45*X19 +X62 =< 0, - -X39 -X43 -X47 +X51 = 0, - +X12 +X15 +X18 +X21 =< 1, - -X22 +X25 +X26 +X27 = 0 - }, - attach_name(X22,'F....F01'), - attach_name(X23,'F....F02'), - attach_name(X24,'F....F03'), - attach_name(X65,'F.C01...'), - attach_name(X66,'F.C02...'), - attach_name(X67,'F.C03...'), - attach_name(X53,'F.D01C01'), - attach_name(X54,'F.D01C02'), - attach_name(X55,'F.D01C03'), - attach_name(X49,'F.D01D01'), - attach_name(X56,'F.D02C01'), - attach_name(X57,'F.D02C02'), - attach_name(X58,'F.D02C03'), - attach_name(X50,'F.D02D02'), - attach_name(X59,'F.D03C01'), - attach_name(X60,'F.D03C02'), - attach_name(X61,'F.D03C03'), - attach_name(X51,'F.D03D03'), - attach_name(X62,'F.D04C01'), - attach_name(X63,'F.D04C02'), - attach_name(X64,'F.D04C03'), - attach_name(X52,'F.D04D04'), - attach_name(X25,'F.F01W01'), - attach_name(X26,'F.F01W02'), - attach_name(X27,'F.F01W03'), - attach_name(X28,'F.F02W01'), - attach_name(X29,'F.F02W02'), - attach_name(X30,'F.F02W03'), - attach_name(X31,'F.F03W01'), - attach_name(X32,'F.F03W02'), - attach_name(X33,'F.F03W03'), - attach_name(X37,'F.W01D01'), - attach_name(X38,'F.W01D02'), - attach_name(X39,'F.W01D03'), - attach_name(X40,'F.W01D04'), - attach_name(X34,'F.W01W01'), - attach_name(X41,'F.W02D01'), - attach_name(X42,'F.W02D02'), - attach_name(X43,'F.W02D03'), - attach_name(X44,'F.W02D04'), - attach_name(X35,'F.W02W02'), - attach_name(X45,'F.W03D01'), - attach_name(X46,'F.W03D02'), - attach_name(X47,'F.W03D03'), - attach_name(X48,'F.W03D04'), - attach_name(X36,'F.W03W03'), - attach_name(X1,'I....F01'), - attach_name(X2,'I....F02'), - attach_name(X3,'I....F03'), - attach_name(X10,'I.D01C01'), - attach_name(X11,'I.D01C02'), - attach_name(X12,'I.D01C03'), - attach_name(X7,'I.D01D01'), - attach_name(X13,'I.D02C01'), - attach_name(X14,'I.D02C02'), - attach_name(X15,'I.D02C03'), - attach_name(X8,'I.D02D02'), - attach_name(X16,'I.D03C01'), - attach_name(X17,'I.D03C02'), - attach_name(X18,'I.D03C03'), - attach_name(X9,'I.D03D03'), - attach_name(X19,'I.D04C01'), - attach_name(X20,'I.D04C02'), - attach_name(X21,'I.D04C03'), - attach_name(X4,'I.W01W01'), - attach_name(X5,'I.W02W02'), - attach_name(X6,'I.W03W03'), - true. - - -% -% Do not edit this file! It was produced automatically by mps2prolog. -% -% NAME: noswot -% ROWS: 182 -% COLUMNS: 128 -% INTEGER: 100 -% NONZERO: 735 -% BEST SOLN: -43 (opt) -% LP SOLN: -43.0 -% SOURCE: -% Linus E. Schrage (U. Chicago) -% John W. Gregory (Cray Research) -% APPLICATION: unknown -% COMMENTS: 75 of the integer variables are binary -% problem originally formulated as a max - changed to min -% -% lp_solve Integerization strategy: -% T455, T454, T453, T452, T451, T355, T354, T353, T345, T352, T344, T351, -% T343, T255, T342, T254, T341, T253, T245, T252, T244, T251, T243, T235, -% T155, T242, T234, T154, T241, T233, T153, T145, T232, T152, T144, T231, -% T151, T143, T135, T142, T134, T141, T133, T125, T132, T124, T131, T123, -% T122, T121, X55, X54, X53, X45, X52, X44, X51, X43, X35, W55, X42, X34, -% W54, X41, X33, X25, W53, W45, X32, X24, W52, W44, X31, X23, X15, W51, -% W43, W35, X22, X14, W42, W34, X21, X13, W41, W33, W25, X12, W32, W24, -% X11, W31, W23, W15, W22, W14, W21, W13, W12, W11 -% -example( noswot, Min, Vs, Ints, Bins) :- - Vs = [X1, X10, X100, X101, X102, X103, X104, X105, X106, X107, X108, - X109, X11, X110, X111, X112, X113, X114, X115, X116, X117, X118, - X119, X12, X120, X121, X122, X123, X124, X125, X126, X127, X128, - X13, X14, X15, X16, X17, X18, X19, X2, X20, X21, X22, X23, X24, X25, - X26, X27, X28, X29, X3, X30, X31, X32, X33, X34, X35, X36, X37, X38, - X39, X4, X40, X41, X42, X43, X44, X45, X46, X47, X48, X49, X5, X50, - X51, X52, X53, X54, X55, X56, X57, X58, X59, X6, X60, X61, X62, X63, - X64, X65, X66, X67, X68, X69, X7, X70, X71, X72, X73, X74, X75, X76, - X77, X78, X79, X8, X80, X81, X82, X83, X84, X85, X86, X87, X88, X89, - X9, X90, X91, X92, X93, X94, X95, X96, X97, X98, X99], -/* - Ints = [X1, X10, X100, X11, X12, X13, X14, X15, X16, X17, X18, X19, - X2, X20, X21, X22, X23, X24, X25, X26, X27, X28, X29, X3, X30, X31, - X32, X33, X34, X35, X36, X37, X38, X39, X4, X40, X41, X42, X43, X44, - X45, X46, X47, X48, X49, X5, X50, X51, X52, X53, X54, X55, X56, X57, - X58, X59, X6, X60, X61, X62, X63, X64, X65, X66, X67, X68, X69, X7, - X70, X71, X72, X73, X74, X75, X76, X77, X78, X79, X8, X80, X81, X82, - X83, X84, X85, X86, X87, X88, X89, X9, X90, X91, X92, X93, X94, X95, - X96, X97, X98, X99], -*/ - Ints = [X50, X49, X48, X47, X46, X45, X44, X86, X40, X84, X39, X82, - X38, X80, X37, X78, X36, X33, X30, X32, X29, X31, X28, X25, - X20, X27, X24, X19, X26, X23, X18, X60, X64, X17, X14, X62, - X16, X13, X10, X12, X9, X94, X8, X5, X7, X4, X6, X3, - X2, X1, X100, X98, X96, X90, X94, X88, X92, X86, X80, X99, X84, X78, - X97, X82, X76, X70, X95, X89, X74, X68, X93, X87, X72, X66, X60, X91, - X85, X79, X64, X58, X83, X77, X62, X56, X81, X75, X69, X98, X73, X67, - X94, X71, X65, X59, X63, X57, X61, X55, X53, X51 - ], - Bins = [], - Min = -X52 -X54 -X56 -X58 -X60 -X62 -X64 -X66 -X68 -X70 -X72 -X74 - - X76 -X78 -X80 -X82 -X84 -X86 -X88 -X90 -X92 -X94 -X96 -X98 -X100, - { - 0 =< X1, X1 =< 1, - 0 =< X10, X10 =< 1, - 0 =< X100, X100 =< 100000, - 0 =< X101, - 0 =< X102, - 0 =< X103, - 0 =< X104, - 0 =< X105, - 0 =< X106, - 0 =< X107, - 0 =< X108, - 0 =< X109, - 0 =< X11, X11 =< 1, - 0 =< X110, - 0 =< X111, - 0 =< X112, - 0 =< X113, - 0 =< X114, - 0 =< X115, - 0 =< X116, - 0 =< X117, - 0 =< X118, - 0 =< X119, - 0 =< X12, X12 =< 1, - 0 =< X120, - 0 =< X121, - 0 =< X122, - 0 =< X123, - 0 =< X124, - 0 =< X125, - 0 =< X126, - 0 =< X127, - 0 =< X128, - 0 =< X13, X13 =< 1, - 0 =< X14, X14 =< 1, - 0 =< X15, X15 =< 1, - 0 =< X16, X16 =< 1, - 0 =< X17, X17 =< 1, - 0 =< X18, X18 =< 1, - 0 =< X19, X19 =< 1, - 0 =< X2, X2 =< 1, - 0 =< X20, X20 =< 1, - 0 =< X21, X21 =< 1, - 0 =< X22, X22 =< 1, - 0 =< X23, X23 =< 1, - 0 =< X24, X24 =< 1, - 0 =< X25, X25 =< 1, - 0 =< X26, X26 =< 1, - 0 =< X27, X27 =< 1, - 0 =< X28, X28 =< 1, - 0 =< X29, X29 =< 1, - 0 =< X3, X3 =< 1, - 0 =< X30, X30 =< 1, - 0 =< X31, X31 =< 1, - 0 =< X32, X32 =< 1, - 0 =< X33, X33 =< 1, - 0 =< X34, X34 =< 1, - 0 =< X35, X35 =< 1, - 0 =< X36, X36 =< 1, - 0 =< X37, X37 =< 1, - 0 =< X38, X38 =< 1, - 0 =< X39, X39 =< 1, - 0 =< X4, X4 =< 1, - 0 =< X40, X40 =< 1, - 0 =< X41, X41 =< 1, - 0 =< X42, X42 =< 1, - 0 =< X43, X43 =< 1, - 0 =< X44, X44 =< 1, - 0 =< X45, X45 =< 1, - 0 =< X46, X46 =< 1, - 0 =< X47, X47 =< 1, - 0 =< X48, X48 =< 1, - 0 =< X49, X49 =< 1, - 0 =< X5, X5 =< 1, - 0 =< X50, X50 =< 1, - 0 =< X51, X51 =< 1, - 0 =< X52, X52 =< 100000, - 0 =< X53, X53 =< 1, - 0 =< X54, X54 =< 100000, - 0 =< X55, X55 =< 1, - 0 =< X56, X56 =< 100000, - 0 =< X57, X57 =< 1, - 0 =< X58, X58 =< 100000, - 0 =< X59, X59 =< 1, - 0 =< X6, X6 =< 1, - 0 =< X60, X60 =< 100000, - 0 =< X61, X61 =< 1, - 0 =< X62, X62 =< 100000, - 0 =< X63, X63 =< 1, - 0 =< X64, X64 =< 100000, - 0 =< X65, X65 =< 1, - 0 =< X66, X66 =< 100000, - 0 =< X67, X67 =< 1, - 0 =< X68, X68 =< 100000, - 0 =< X69, X69 =< 1, - 0 =< X7, X7 =< 1, - 0 =< X70, X70 =< 100000, - 0 =< X71, X71 =< 1, - 0 =< X72, X72 =< 100000, - 0 =< X73, X73 =< 1, - 0 =< X74, X74 =< 100000, - 0 =< X75, X75 =< 1, - 0 =< X76, X76 =< 100000, - 0 =< X77, X77 =< 1, - 0 =< X78, X78 =< 100000, - 0 =< X79, X79 =< 1, - 0 =< X8, X8 =< 1, - 0 =< X80, X80 =< 100000, - 0 =< X81, X81 =< 1, - 0 =< X82, X82 =< 100000, - 0 =< X83, X83 =< 1, - 0 =< X84, X84 =< 100000, - 0 =< X85, X85 =< 1, - 0 =< X86, X86 =< 100000, - 0 =< X87, X87 =< 1, - 0 =< X88, X88 =< 100000, - 0 =< X89, X89 =< 1, - 0 =< X9, X9 =< 1, - 0 =< X90, X90 =< 100000, - 0 =< X91, X91 =< 1, - 0 =< X92, X92 =< 100000, - 0 =< X93, X93 =< 1, - 0 =< X94, X94 =< 100000, - 0 =< X95, X95 =< 1, - 0 =< X96, X96 =< 100000, - 0 =< X97, X97 =< 1, - 0 =< X98, X98 =< 100000, - 0 =< X99, X99 =< 1, - -20*X75 +3.4721999*X76 +X113 =< 0, - -21*X50 -0.25*X89 -2.2400999*X90 -X120 +X125 >= -21, - -21*X40 -0.666700006*X79 -3.4721999*X80 -X115 +X120 >= -21, - -X55 +X56 >= 0, - -X81 +X82 >= 0, - -21*X29 -0.666700006*X67 -2.9762001*X68 -X109 +X119 >= -21, - +21*X26 -0.75*X81 -2.2400999*X82 +X106 -X116 >= 0, - -21*X22 -0.666700006*X63 -2.9762001*X64 -X107 +X112 >= -21, - -X71 +X72 >= 0, - -16*X59 +2.0833001*X60 +X105 =< 0, - -21*X39 -0.666700006*X77 -3.4721999*X78 -X114 +X119 >= -21, - -8.9280005*X83 +X84 +X126 = 0, - +21*X17 -0.666700006*X93 -2.0833001*X94 +X102 -X122 >= 0, - -21*X13 -0.25*X55 -2.0833001*X56 -X103 +X118 >= -21, - +21*X10 -0.666700006*X79 -3.4721999*X80 +X105 -X115 >= 0, - -21*X6 -0.666700006*X51 -2.0833001*X52 -X101 +X111 >= -21, - +X82 +X84 +X86 +X88 +X90 =< 1, - -20*X77 +3.4721999*X78 +X114 =< 0, - +21*X41 -0.666700006*X91 -2.0833001*X92 +X111 -X121 >= 0, - -8.9280005*X81 +X82 +X127 = 0, - -20*X95 +2.0833001*X96 +X123 =< 0, - -5.7600002*X71 +X72 =< 0, - -6.7199998*X63 +X64 =< 0, - -21*X24 -0.666700006*X67 -2.9762001*X68 -X109 +X114 >= -21, - +21*X21 -0.75*X71 -3.4721999*X72 +X106 -X111 >= 0, - +21*X40 -0.666700006*X89 -2.2400999*X90 +X115 -X120 >= 0, - -X85 +X86 >= 0, - +X52 +X54 +X56 +X58 +X60 +X62 +X64 +X66 +X68 +X70 +X72 +X74 +X76 - +X78 +X80 +X82 +X84 +X86 +X88 +X90 +X92 +X94 +X96 +X98 +X100 =< 43, - -20*X91 +2.0833001*X92 +X121 =< 0, - -21*X41 -0.666700006*X71 -3.4721999*X72 -X111 +X121 >= -21, - +21*X12 -0.25*X83 -2.2400999*X84 +X102 -X117 >= 0, - -21*X1 -0.75*X51 -2.0833001*X52 -X101 +X106 >= -21, - +21*X5 -0.666700006*X69 -2.9762001*X70 +X105 -X110 >= 0, - -21*X8 -0.666700006*X55 -2.0833001*X56 -X103 +X113 >= -21, - +21*X33 -0.75*X95 -2.0833001*X96 +X108 -X123 >= 0, - -X83 +X84 >= 0, - -20*X97 +2.0833001*X98 +X124 =< 0, - -X73 +X74 >= 0, - -8.9280005*X85 +X86 +2*X128 =< 0, - -6.7199998*X67 +X68 =< 0, - -X61 +X62 >= 0, - -21*X20 -0.25*X59 -2.0833001*X60 -X105 +X125 >= -21, - -20*X93 +2.0833001*X94 +X122 =< 0, - +21*X42 -0.666700006*X93 -2.0833001*X94 +X112 -X122 >= 0, - -X59 +X60 >= 0, - -21*X3 -0.75*X55 -2.0833001*X56 -X103 +X108 >= -21, - +21*X7 -0.666700006*X73 -3.4721999*X74 +X102 -X112 >= 0, - -16*X99 +2.0833001*X100 +X125 =< 0, - -5.7600002*X73 +X74 =< 0, - -21*X31 -0.666700006*X61 -2.9762001*X62 -X106 +X121 >= -21, - +21*X28 -0.75*X85 -2.2400999*X86 +X108 -X118 >= 0, - -X87 +X88 >= 0, - -20*X65 +2.9762001*X66 +X108 =< 0, - -20*X55 +2.0833001*X56 +X103 =< 0, - -21*X15 -0.25*X59 -2.0833001*X60 -X105 +X120 >= -21, - +21*X19 -0.666700006*X97 -2.0833001*X98 +X104 -X124 >= 0, - -21*X42 -0.666700006*X73 -3.4721999*X74 -X112 +X122 >= -21, - -X91 +X92 >= 0, - -X75 +X76 >= 0, - -9.6000004*X55 +X56 =< 0, - +21*X2 -0.666700006*X63 -2.9762001*X64 +X102 -X107 >= 0, - +21*X30 -0.75*X89 -2.2400999*X90 +X110 -X120 >= 0, - +21*X23 -0.75*X75 -3.4721999*X76 +X108 -X113 >= 0, - -21*X26 -0.666700006*X61 -2.9762001*X62 -X106 +X116 >= -21, - -8.9280005*X87 +X88 +3*X128 =< 0, - +21*X43 -0.666700006*X95 -2.0833001*X96 +X113 -X123 >= 0, - -21*X10 -0.666700006*X59 -2.0833001*X60 -X105 +X115 >= -21, - +21*X14 -0.25*X87 -2.2400999*X88 +X104 -X119 >= 0, - -21*X17 -0.25*X53 -2.0833001*X54 -X102 +X122 >= -21, - -9.6000004*X91 +X92 =< 0, - -5.7600002*X75 +X76 =< 0, - -X89 +X90 >= 0, - -X53 +X54 >= 0, - -X65 +X66 >= 0, - -21*X21 -0.666700006*X61 -2.9762001*X62 -X106 +X111 >= -21, - +21*X25 -0.75*X79 -3.4721999*X80 +X110 -X115 >= 0, - -X51 +X52 >= 0, - -21*X43 -0.666700006*X75 -3.4721999*X76 -X113 +X123 >= -21, - +21*X34 -0.75*X97 -2.0833001*X98 +X109 -X124 >= 0, - -X93 +X94 >= 0, - -X77 +X78 >= 0, - +21*X9 -0.666700006*X77 -3.4721999*X78 +X104 -X114 >= 0, - -21*X5 -0.75*X59 -2.0833001*X60 -X105 +X110 >= -21, - -21*X12 -0.25*X53 -2.0833001*X54 -X102 +X117 >= -21, - -21*X33 -0.666700006*X65 -2.9762001*X66 -X108 +X123 >= -21, - -7.1423998*X89 +X90 +4*X128 =< 0, - -4.6079998*X79 +X80 =< 0, - -X69 +X70 >= 0, - -6.7199998*X61 +X62 =< 0, - +21*X44 -0.666700006*X97 -2.0833001*X98 +X114 -X124 >= 0, - +X52 +X54 +X56 +X58 +X60 =< 38, - -21*X34 -0.666700006*X67 -2.9762001*X68 -X109 +X124 >= -21, - -20*X51 +2.0833001*X52 +X101 =< 0, - -9.6000004*X93 +X94 =< 0, - -5.7600002*X77 +X78 =< 0, - -21*X45 -0.666700006*X79 -3.4721999*X80 -X115 +X125 >= -21, - -7.6799998*X59 +X60 =< 0, - +21*X4 -0.666700006*X67 -2.9762001*X68 +X104 -X109 >= 0, - -21*X7 -0.666700006*X53 -2.0833001*X54 -X102 +X112 >= -21, - -21*X28 -0.666700006*X65 -2.9762001*X66 -X108 +X118 >= -21, - +21*X32 -0.75*X93 -2.0833001*X94 +X107 -X122 >= 0, - +21*X46 -0.666700006*X91 -2.0833001*X92 +X116 -X121 >= 0, - +21*X36 -0.666700006*X81 -2.2400999*X82 +X111 -X116 >= 0, - -21*X44 -0.666700006*X77 -3.4721999*X78 -X114 +X124 >= -21, - +21*X35 -0.75*X99 -2.0833001*X100 +X110 -X125 >= 0, - -21*X47 -0.25*X83 -2.2400999*X84 -X117 +X122 >= -21, - -20*X67 +2.9762001*X68 +X109 =< 0, - +21*X16 -0.666700006*X91 -2.0833001*X92 +X101 -X121 >= 0, - -21*X19 -0.25*X57 -2.0833001*X58 -X104 +X124 >= -21, - -X95 +X96 >= 0, - -X79 +X80 >= 0, - +X72 +X74 +X76 +X78 +X80 =< 2, - -21*X46 -0.25*X81 -2.2400999*X82 -X116 +X121 >= -21, - -9.6000004*X97 +X98 =< 0, - -X57 +X58 >= 0, - -21*X2 -0.75*X53 -2.0833001*X54 -X102 +X107 >= -21, - -21*X36 -0.666700006*X71 -3.4721999*X72 -X111 +X116 >= -21, - -21*X23 -0.666700006*X65 -2.9762001*X66 -X108 +X113 >= -21, - +21*X27 -0.75*X83 -2.2400999*X84 +X107 -X117 >= 0, - -21*X30 -0.666700006*X69 -2.9762001*X70 -X110 +X120 >= -21, - +21*X45 -0.666700006*X99 -2.0833001*X100 +X115 -X125 >= 0, - -21*X35 -0.666700006*X69 -2.9762001*X70 -X110 +X125 >= -21, - +21*X48 -0.666700006*X95 -2.0833001*X96 +X118 -X123 >= 0, - -9.6000004*X95 +X96 =< 0, - -20*X57 +2.0833001*X58 +X104 =< 0, - -20*X81 +2.2400999*X82 +X116 =< 0, - +21*X11 -0.25*X81 -2.2400999*X82 +X101 -X116 >= 0, - -21*X14 -0.25*X57 -2.0833001*X58 -X104 +X119 >= -21, - +21*X18 -0.666700006*X95 -2.0833001*X96 +X103 -X123 >= 0, - +21*X47 -0.666700006*X93 -2.0833001*X94 +X117 -X122 >= 0, - -X99 +X100 >= 0, - +21*X37 -0.666700006*X83 -2.2400999*X84 +X112 -X117 >= 0, - -9.6000004*X53 +X54 =< 0, - -6.7199998*X65 +X66 =< 0, - +X62 +X64 +X66 +X68 +X70 >= 5, - +21*X22 -0.75*X73 -3.4721999*X74 +X107 -X112 >= 0, - -21*X25 -0.666700006*X69 -2.9762001*X70 -X110 +X115 >= -21, - +21*X29 -0.75*X87 -2.2400999*X88 +X109 -X119 >= 0, - -21*X48 -0.25*X85 -2.2400999*X86 -X118 +X123 >= -21, - -X97 +X98 >= 0, - -20*X83 +2.2400999*X84 +X117 =< 0, - +21*X13 -0.25*X85 -2.2400999*X86 +X103 -X118 >= 0, - -21*X9 -0.666700006*X57 -2.0833001*X58 -X104 +X114 >= -21, - +21*X6 -0.666700006*X71 -3.4721999*X72 +X101 -X111 >= 0, - -7.6799998*X99 +X100 =< 0, - -21*X37 -0.666700006*X73 -3.4721999*X74 -X112 +X117 >= -21, - +X62 +X64 +X66 +X68 +X70 =< 9, - +21*X49 -0.666700006*X97 -2.0833001*X98 +X119 -X124 >= 0, - -5.3759999*X69 +X70 =< 0, - -X63 +X64 >= 0, - -20*X61 +2.9762001*X62 +X106 =< 0, - +21*X24 -0.75*X77 -3.4721999*X78 +X109 -X114 >= 0, - -20*X85 +2.2400999*X86 +X118 =< 0, - -9.6000004*X51 +X52 =< 0, - +X92 +X94 +X96 +X98 +X100 =< 2, - +21*X38 -0.666700006*X85 -2.2400999*X86 +X113 -X118 >= 0, - +21*X8 -0.666700006*X75 -3.4721999*X76 +X103 -X113 >= 0, - -21*X4 -0.75*X57 -2.0833001*X58 -X104 +X109 >= -21, - +21*X1 -0.666700006*X61 -2.9762001*X62 +X101 -X106 >= 0, - -21*X32 -0.666700006*X63 -2.9762001*X64 -X107 +X122 >= -21, - -20*X71 +3.4721999*X72 +X111 =< 0, - -21*X49 -0.25*X87 -2.2400999*X88 -X119 +X124 >= -21, - -20*X87 +2.2400999*X88 +X119 =< 0, - -16*X69 +2.9762001*X70 +X110 =< 0, - -X67 +X68 >= 0, - +21*X20 -0.666700006*X99 -2.0833001*X100 +X105 -X125 >= 0, - -21*X16 -0.25*X51 -2.0833001*X52 -X101 +X121 >= -21, - -20*X53 +2.0833001*X54 +X102 =< 0, - -21*X38 -0.666700006*X75 -3.4721999*X76 -X113 +X118 >= -21, - -20*X73 +3.4721999*X74 +X112 =< 0, - -9.6000004*X57 +X58 =< 0, - +21*X3 -0.666700006*X65 -2.9762001*X66 +X103 -X108 >= 0, - +21*X50 -0.666700006*X99 -2.0833001*X100 +X120 -X125 >= 0, - -21*X27 -0.666700006*X63 -2.9762001*X64 -X107 +X117 >= -21, - +21*X31 -0.75*X91 -2.0833001*X92 +X106 -X121 >= 0, - -16*X89 +2.2400999*X90 +X120 =< 0, - -16*X79 +3.4721999*X80 +X115 =< 0, - -20*X63 +2.9762001*X64 +X107 =< 0, - -21*X18 -0.25*X55 -2.0833001*X56 -X103 +X123 >= -21, - +21*X15 -0.25*X89 -2.2400999*X90 +X105 -X120 >= 0, - -21*X11 -0.25*X51 -2.0833001*X52 -X101 +X116 >= -21, - +21*X39 -0.666700006*X87 -2.2400999*X88 +X114 -X119 >= 0 - }, - attach_name(X128,'Q246'), - attach_name(X101,'S11'), - attach_name(X102,'S12'), - attach_name(X103,'S13'), - attach_name(X104,'S14'), - attach_name(X105,'S15'), - attach_name(X106,'S21'), - attach_name(X107,'S22'), - attach_name(X108,'S23'), - attach_name(X109,'S24'), - attach_name(X110,'S25'), - attach_name(X111,'S31'), - attach_name(X112,'S32'), - attach_name(X113,'S33'), - attach_name(X114,'S34'), - attach_name(X115,'S35'), - attach_name(X116,'S41'), - attach_name(X117,'S42'), - attach_name(X118,'S43'), - attach_name(X119,'S44'), - attach_name(X120,'S45'), - attach_name(X121,'S51'), - attach_name(X122,'S52'), - attach_name(X123,'S53'), - attach_name(X124,'S54'), - attach_name(X125,'S55'), - attach_name(X1,'T121'), - attach_name(X2,'T122'), - attach_name(X3,'T123'), - attach_name(X4,'T124'), - attach_name(X5,'T125'), - attach_name(X6,'T131'), - attach_name(X7,'T132'), - attach_name(X8,'T133'), - attach_name(X9,'T134'), - attach_name(X10,'T135'), - attach_name(X11,'T141'), - attach_name(X12,'T142'), - attach_name(X13,'T143'), - attach_name(X14,'T144'), - attach_name(X15,'T145'), - attach_name(X16,'T151'), - attach_name(X17,'T152'), - attach_name(X18,'T153'), - attach_name(X19,'T154'), - attach_name(X20,'T155'), - attach_name(X21,'T231'), - attach_name(X22,'T232'), - attach_name(X23,'T233'), - attach_name(X24,'T234'), - attach_name(X25,'T235'), - attach_name(X26,'T241'), - attach_name(X27,'T242'), - attach_name(X28,'T243'), - attach_name(X29,'T244'), - attach_name(X30,'T245'), - attach_name(X31,'T251'), - attach_name(X32,'T252'), - attach_name(X33,'T253'), - attach_name(X34,'T254'), - attach_name(X35,'T255'), - attach_name(X36,'T341'), - attach_name(X37,'T342'), - attach_name(X38,'T343'), - attach_name(X39,'T344'), - attach_name(X40,'T345'), - attach_name(X41,'T351'), - attach_name(X42,'T352'), - attach_name(X43,'T353'), - attach_name(X44,'T354'), - attach_name(X45,'T355'), - attach_name(X46,'T451'), - attach_name(X47,'T452'), - attach_name(X48,'T453'), - attach_name(X49,'T454'), - attach_name(X50,'T455'), - attach_name(X127,'V148'), - attach_name(X126,'V150'), - attach_name(X51,'W11'), - attach_name(X53,'W12'), - attach_name(X55,'W13'), - attach_name(X57,'W14'), - attach_name(X59,'W15'), - attach_name(X61,'W21'), - attach_name(X63,'W22'), - attach_name(X65,'W23'), - attach_name(X67,'W24'), - attach_name(X69,'W25'), - attach_name(X71,'W31'), - attach_name(X73,'W32'), - attach_name(X75,'W33'), - attach_name(X77,'W34'), - attach_name(X79,'W35'), - attach_name(X81,'W41'), - attach_name(X83,'W42'), - attach_name(X85,'W43'), - attach_name(X87,'W44'), - attach_name(X89,'W45'), - attach_name(X91,'W51'), - attach_name(X93,'W52'), - attach_name(X95,'W53'), - attach_name(X97,'W54'), - attach_name(X99,'W55'), - attach_name(X52,'X11'), - attach_name(X54,'X12'), - attach_name(X56,'X13'), - attach_name(X58,'X14'), - attach_name(X60,'X15'), - attach_name(X62,'X21'), - attach_name(X64,'X22'), - attach_name(X66,'X23'), - attach_name(X68,'X24'), - attach_name(X70,'X25'), - attach_name(X72,'X31'), - attach_name(X74,'X32'), - attach_name(X76,'X33'), - attach_name(X78,'X34'), - attach_name(X80,'X35'), - attach_name(X82,'X41'), - attach_name(X84,'X42'), - attach_name(X86,'X43'), - attach_name(X88,'X44'), - attach_name(X90,'X45'), - attach_name(X92,'X51'), - attach_name(X94,'X52'), - attach_name(X96,'X53'), - attach_name(X98,'X54'), - attach_name(X100,'X55'), - true. - -/* - -lp_solve has problems with this one: - -Error: rhsmincol called with rownr: 185, Rows: 182 -This indicates numerical instability -If this happened with a small model, please send it to michel@es.ele.tue.nl -440.100u 0.390s 17:20.09 42.3% 0+401k 6+0io 8pf+0w - -| ?- example(noswot). -incumbent(-37507399360171328215441611691007/956819227975228289496672500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,84858086996886989418093669/956819227975228289496672500000,3,0,0,0,2,5,0,0,0,0,4,0,0,0,6,0,0,0,0,5892922503501787338/382727691190091315798669,1,0,0,1,1,0,1,0,1,1,1]) -incumbent(-20679553649402263964041653892005232507098192277/527357499396939193162537760967541655971250000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,84858086996886989418093669/956819227975228289496672500000,3,0,0,1,1,5,0,0,0,0,4,0,0,1,7,0,0,0,0,5892922503501787338/382727691190091315798669,1,0,1,1,1,0,1,1,1,1,1]) -incumbent(-38464218588146556504938284191007/956819227975228289496672500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,84858086996886989418093669/956819227975228289496672500000,5,0,0,0,0,5,0,0,0,0,2,0,0,0,9,0,0,0,0,5892922503501787338/382727691190091315798669,1,0,0,0,1,0,1,0,1,1,1]) -incumbent(-21206911148799203157204191652972774163069442277/527357499396939193162537760967541655971250000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,84858086996886989418093669/956819227975228289496672500000,4,0,0,1,0,5,0,0,0,0,3,0,0,1,9,0,0,0,0,5892922503501787338/382727691190091315798669,1,0,1,0,1,0,1,1,1,1,1]) -incumbent(-782167041139900591606331/19290490762765827500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,0,5,0,0,0,0,4,0,0,2,9,0,0,0,0,0,1,0,1,0,1,0,1,1,1,1,1]) -incumbent(-314807692893068268/7716196305106331,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,5,0,0,0,1,6,0,0,2,9,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1]) -incumbent(-316644793474061606/7716196305106331,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,1,0,5,0,0,0,1,6,0,0,2,9,0,0,0,0,1,1,0,1,0,1,1,1,1,1,1,1]) -incumbent(-802375152901385609106331/19290490762765827500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1913565439163003113010581906331/956825148625000000000000000000,2,0,0,84858086996886989418093669/956825148625000000000000000000,0,5,0,0,0,3,6,0,0,0,9,0,0,0,0,1,1,0,2946461251750893669/191365029725000000000000,0,1,1,1,0,1,1,1]) -incumbent(-810643034807633109106331/19290490762765827500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,1,0,5,0,0,0,0,6,0,0,2,9,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,1]) -incumbent(-820748022665432246606331/19290490762765827500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,2,0,5,0,0,0,0,6,0,0,2,9,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,1]) -incumbent(-821665643664151436606331/19290490762765827500000,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,2,2,0,0,0,0,5,0,0,0,3,6,0,0,0,9,0,0,1,0,1,1,0,0,0,1,1,1,0,1,1,1]) -incumbent(-330607133902768606/7716196305106331,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,5,0,0,0,2,9,0,0,2,9,0,0,1,0,1,0,0,1,0,1,1,1,1,1,1,1]) -incumbent(-43,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,382727112988748249106331/191365029725000000000000,0,0,0,2946461251750893669/191365029725000000000000,0,5,0,0,0,4,9,0,0,0,9,0,0,1,0,1,0,0,2946461251750893669/191365029725000000000000,0,1,1,1,0,1,1,1]) -noswot:-43 -%%% Timing 01:04:49.840 3889.840 -*/ - - -% -% Do not edit this file! It was produced automatically by mps2prolog. -% -% NAME: bell3a -% ROWS: 123 -% COLUMNS: 133 -% INTEGER: 71 -% NONZERO: 347 -% BEST SOLN: 878430.32 (opt) -% LP SOLN: 862578.64 -% SOURCE: William Cook (Bellcore) -% William Cook (Bellcore) -% William Cook (Bellcore) -% APPLICATION: fiber optic network design -% COMMENTS: 39 of the integer variables are binary -% hard problem -% solved with new code based on Lovasz-Scarf basis reduction -% -% lp_solve Integerization strategy: -% h17, h16, h15, g17, h21, h13, g16, h20, h12, g15, h10, g21, g13, g20, -% g12, g10, d17, d16, d15, c19, c18, d21, d13, c17, d20, d12, c16, c23, -% c15, d10, c22, c14, c21, c13, c20, c12, c11, c10, h9, g9, h7, h6, g7, -% h5, g6, h4, g5, h3, g4, h2, g3, h1, d9, g2, g1, d7, c9, d6, c8, d5, -% c7, d4, c6, d3, c5, d2, c4, d1, c3, c2, c1 -% -example( bell3a, Min, Vs, Ints, Bins) :- - Vs = [X1, X10, X100, X101, X102, X103, X104, X105, X106, X107, X108, - X109, X11, X110, X111, X112, X113, X114, X115, X116, X117, X118, - X119, X12, X120, X121, X122, X123, X124, X125, X126, X127, X128, - X129, X13, X130, X131, X132, X133, X14, X15, X16, X17, X18, X19, X2, - X20, X21, X22, X23, X24, X25, X26, X27, X28, X29, X3, X30, X31, X32, - X33, X34, X35, X36, X37, X38, X39, X4, X40, X41, X42, X43, X44, X45, - X46, X47, X48, X49, X5, X50, X51, X52, X53, X54, X55, X56, X57, X58, - X59, X6, X60, X61, X62, X63, X64, X65, X66, X67, X68, X69, X7, X70, - X71, X72, X73, X74, X75, X76, X77, X78, X79, X8, X80, X81, X82, X83, - X84, X85, X86, X87, X88, X89, X9, X90, X91, X92, X93, X94, X95, X96, - X97, X98, X99], -/**/ - Ints = [X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, - X15, X16, X17, X18, X19, X20, X21, X22, X23, X24, X25, X26, X27, - X28, X29, X30, X31, X32, X33, X34, X35, X36, X37, X38, X39, X40, - X41, X42, X43, X44, X45, X46, X47, X48, X49, X50, X51, X52, X53, - X54, X55, X56, X57, X58, X59, X60, X61, X62, X63, X64, X65, X66, - X67, X68, X69, X70, X71], -/**/ -/* -% -% lp_solve Integerization strategy: -% - Ints = [ - X53, X52, X51, X69, X55, X50, X68, X54, X49, X67, X48, X71, X66, X70, - X65, X64, X37, X36, X35, X19, X18, X39, X34, X17, X38, X33, X16, X23, - X15, X32, X22, X14, X21, X13, X20, X12, X11, X10, X47, X63, X46, X45, X62, - X44, X61, X43, X60, X42, X59, X41, X58, X40, X31, X57, X56, X30, X9, X29, X8, X28, - X7, X27, X6, X26, X5, X25, X4, X24, X3, X2, X1 ], -*/ - Bins = [], - Min = +43000*X24 +43000*X25 +43000*X26 +43000*X27 +43000*X28 - +43000*X29 +43000*X30 +43000*X31 +43000*X32 +43000*X33 +43000*X34 - +43000*X35 +43000*X36 +44000*X37 +43000*X38 +43000*X39 +58000*X40 - +58000*X41 +58000*X42 +58000*X43 +58000*X44 +58000*X45 +59000*X46 - +60000*X47 +59000*X48 +59000*X49 +59000*X50 +59000*X51 +59000*X52 - +60000*X53 +59000*X54 +59000*X55 +10000*X56 +10000*X57 +10000*X58 - +10000*X59 +10000*X60 +10000*X61 +10000*X62 +10000*X63 +10000*X64 - +10000*X65 +10000*X66 +10000*X67 +10000*X68 +10000*X69 +10000*X70 - +10000*X71 +12.775*X72 +16.425*X73 +18.25*X74 +21.17*X75 +18.98*X76 - +14.6*X77 +36.5*X78 +73*X79 +73*X80 +18.25*X81 +10.95*X82 +21.9*X83 - +51.1*X84 +10.585*X85 +80.8475*X86 +88.5125*X87 +95.63*X88 - +25.55*X89 +14.6*X90 +58.4*X91 +73*X92 +21.9*X93 +0.073*X94 - +1.2775*X95 +1.6425*X96 +1.825*X97 +2.117*X98 +1.898*X99 +1.46*X100 - +3.65*X101 +7.3*X102 +7.3*X103 +1.825*X104 +1.095*X105 +2.19*X106 - +5.11*X107 +1.0585*X108 +8.08475*X109 +8.85125*X110 +9.563*X111 - +2.555*X112 +1.46*X113 +5.84*X114 +7.3*X115 +2.19*X116 +0.0073*X117, - { - 0 =< X1, X1 =< 1, - 0 =< X10, X10 =< 1, - 0 =< X100, - 0 =< X101, - 0 =< X102, - 0 =< X103, - 0 =< X104, - 0 =< X105, - 0 =< X106, - 0 =< X107, - 0 =< X108, - 0 =< X109, - 0 =< X11, X11 =< 1, - 0 =< X110, - 0 =< X111, - 0 =< X112, - 0 =< X113, - 0 =< X114, - 0 =< X115, - 0 =< X116, - 0 =< X117, - 0 =< X118, - 0 =< X119, - 0 =< X12, X12 =< 1, - 0 =< X120, - 0 =< X121, - 0 =< X122, - 0 =< X123, - 0 =< X124, - 0 =< X125, - 0 =< X126, - 0 =< X127, - 0 =< X128, - 0 =< X129, - 0 =< X13, X13 =< 1, - 0 =< X130, - 0 =< X131, - 0 =< X132, - 0 =< X133, - 0 =< X14, X14 =< 1, - 0 =< X15, X15 =< 1, - 0 =< X16, X16 =< 1, - 0 =< X17, X17 =< 1, - 0 =< X18, X18 =< 1, - 0 =< X19, X19 =< 1, - 0 =< X2, X2 =< 1, - 0 =< X20, X20 =< 1, - 0 =< X21, X21 =< 1, - 0 =< X22, X22 =< 1, - 0 =< X23, X23 =< 1, - 0 =< X24, X24 =< 1, - 0 =< X25, X25 =< 1, - 0 =< X26, X26 =< 1, - 0 =< X27, X27 =< 1, - 0 =< X28, X28 =< 1, - 0 =< X29, X29 =< 1, - 0 =< X3, X3 =< 1, - 0 =< X30, X30 =< 1, - 0 =< X31, X31 =< 1, - 0 =< X32, X32 =< 1, - 0 =< X33, X33 =< 1, - 0 =< X34, X34 =< 1, - 0 =< X35, X35 =< 1, - 0 =< X36, X36 =< 1, - 0 =< X37, X37 =< 1, - 0 =< X38, X38 =< 1, - 0 =< X39, X39 =< 1, - 0 =< X4, X4 =< 1, - 0 =< X40, X40 =< 1000, - 0 =< X41, X41 =< 1000, - 0 =< X42, X42 =< 1000, - 0 =< X43, X43 =< 1000, - 0 =< X44, X44 =< 1000, - 0 =< X45, X45 =< 1000, - 0 =< X46, X46 =< 1000, - 0 =< X47, X47 =< 1000, - 0 =< X48, X48 =< 1000, - 0 =< X49, X49 =< 1000, - 0 =< X5, X5 =< 1, - 0 =< X50, X50 =< 1000, - 0 =< X51, X51 =< 1000, - 0 =< X52, X52 =< 1000, - 0 =< X53, X53 =< 1000, - 0 =< X54, X54 =< 1000, - 0 =< X55, X55 =< 1000, - 0 =< X56, X56 =< 1000, - 0 =< X57, X57 =< 1000, - 0 =< X58, X58 =< 1000, - 0 =< X59, X59 =< 1000, - 0 =< X6, X6 =< 1, - 0 =< X60, X60 =< 1000, - 0 =< X61, X61 =< 1000, - 0 =< X62, X62 =< 1000, - 0 =< X63, X63 =< 1000, - 0 =< X64, X64 =< 1000, - 0 =< X65, X65 =< 1000, - 0 =< X66, X66 =< 1000, - 0 =< X67, X67 =< 1000, - 0 =< X68, X68 =< 1000, - 0 =< X69, X69 =< 1000, - 0 =< X7, X7 =< 1, - 0 =< X70, X70 =< 1000, - 0 =< X71, X71 =< 1000, - 0 =< X72, - 0 =< X73, - 0 =< X74, - 0 =< X75, - 0 =< X76, - 0 =< X77, - 0 =< X78, - 0 =< X79, - 0 =< X8, X8 =< 1, - 0 =< X80, - 0 =< X81, - 0 =< X82, - 0 =< X83, - 0 =< X84, - 0 =< X85, - 0 =< X86, - 0 =< X87, - 0 =< X88, - 0 =< X89, - 0 =< X9, X9 =< 1, - 0 =< X90, - 0 =< X91, - 0 =< X92, - 0 =< X93, - 0 =< X94, - 0 =< X95, - 0 =< X96, - 0 =< X97, - 0 =< X98, - 0 =< X99 }, - { - -X72 +X73 -X118 =< -100, - -24*X59 +X121 =< 0, - -672*X30 -1344*X46 -X101 +X102 +X115 +X124 =< 0, - -X90 +X91 =< 0, - +X19 +8.33E-4*X90 +8.3E-5*X113 =< 1, - -X108 =< 0, - -X83 +X84 -X127 =< -160, - -24*X66 +X128 =< 0, - -X16 +X17 =< 0, - -20*X15 +X35 +X51 =< 0, - +X12 +8.33E-4*X83 +8.3E-5*X106 =< 3, - -X77 +X78 +X90 +X93 +X94 -X123 =< 0, - -24*X63 +X125 =< 0, - +X4 +8.33E-4*X75 +8.3E-5*X98 =< 1, - -X93 =< -100, - +X22 +8.33E-4*X93 +8.3E-5*X116 =< 13, - +X9 +8.33E-4*X80 +8.3E-5*X103 =< 2, - -X5 +X6 =< 0, - -20*X2 +X25 +X41 =< 0, - +X20 +8.33E-4*X91 +8.3E-5*X114 =< 1, - -X84 -X128 =< -100, - -24*X56 +X118 =< 0, - -672*X35 -1344*X51 -X109 +X110 +X129 =< 0, - -672*X27 -1344*X43 -X98 +X99 +X121 =< 0, - -X17 +X18 =< 0, - -20*X16 +X36 +X52 =< 0, - +X13 +8.33E-4*X84 +8.3E-5*X107 =< 2, - -20*X7 +X30 +X46 =< 0, - -X10 +X11 =< 0, - -X94 =< -50, - -X74 +X75 -X120 =< -200, - -24*X61 +X123 =< 0, - -672*X31 -1344*X47 -X103 +X125 =< 0, - +X23 +8.33E-4*X94 +8.3E-5*X117 =< 99, - +X1 +8.33E-4*X72 +8.3E-5*X95 =< 2, - -X7 +X21 =< 0, - -X79 +X80 =< -10, - +X6 +8.33E-4*X77 +8.3E-5*X100 =< 13, - -X2 +X3 =< 0, - -X85 =< -300, - -24*X67 +X129 =< 0, - -672*X36 -1344*X52 -X110 +X111 +X130 =< 0, - -20*X17 +X37 +X53 =< 0, - +X14 +8.33E-4*X85 +8.3E-5*X108 =< 2, - -X6 +X19 =< 0, - -X11 +X12 =< 0, - -20*X10 +X32 +X48 =< 0, - -672*X24 -1344*X40 -X95 +X96 +X118 =< 0, - -20*X4 +X27 +X43 =< 0, - -X7 +X8 =< 0, - -20*X20 +X38 +X54 =< 0, - -X6 +X22 =< 0, - -24*X58 +X120 =< 0, - -672*X29 -1344*X45 -X100 +X101 +X113 +X116 +X117 +X123 =< 0, - -20*X9 +X31 +X47 =< 0, - -X76 +X77 +X81 +X86 -X122 =< 0, - +X3 +8.33E-4*X74 +8.3E-5*X97 =< 2, - -X86 +X87 -X129 =< -100, - -24*X68 +X130 =< 0, - -672*X37 -1344*X53 -X111 +X112 +X131 =< 0, - -X19 +X20 =< 0, - +X15 +8.33E-4*X86 +8.3E-5*X109 =< 2, - -672*X32 -1344*X48 -X104 +X105 +X108 +X126 =< 0, - -X12 +X13 =< 0, - +X8 +8.33E-4*X79 +8.3E-5*X102 =< 1, - -672*X38 -1344*X54 -X114 +X132 =< 0, - -20*X21 +X39 +X55 =< 0, - -20*X1 +X24 +X40 =< 0, - -X4 +X5 =< 0, - -X6 +X23 =< 0, - -672*X26 -1344*X42 -X97 +X98 +X120 =< 0, - -X5 +X10 =< 0, - -20*X6 +X29 +X45 =< 0, - -X112 =< 0, - -X87 +X88 -X130 =< -150, - -24*X69 +X131 =< 0, - +X16 +8.33E-4*X87 +8.3E-5*X110 =< 2, - -X105 +X106 =< 0, - -X102 +X103 =< 0, - -X73 +X74 -X119 =< -50, - -24*X64 +X126 =< 0, - -24*X60 +X122 =< 0, - -20*X12 +X33 +X49 =< 0, - -X10 +X14 =< 0, - -X78 +X79 +X92 -X124 =< -150, - -24*X70 +X132 =< 0, - -672*X39 -1344*X55 -X115 +X133 =< 0, - +X5 +8.33E-4*X76 +8.3E-5*X99 =< 1, - -X1 +X2 =< 0, - +X10 +8.33E-4*X81 +8.3E-5*X104 =< 13, - -X113 +X114 =< 0, - -X88 +X89 -X131 =< -10, - +X17 +8.33E-4*X88 +8.3E-5*X111 =< 2, - -20*X3 +X26 +X42 =< 0, - -X6 +X7 =< 0, - -X81 +X82 +X85 -X126 =< 0, - -672*X33 -1344*X49 -X106 +X107 +X127 =< 0, - -20*X13 +X34 +X50 =< 0, - -X5 +X15 =< 0, - -24*X57 +X119 =< 0, - -672*X28 -1344*X44 -X99 +X100 +X104 +X109 +X122 =< 0, - -X116 =< 0, - -X91 -X132 =< -600, - -24*X71 +X133 =< 0, - -X75 +X76 -X121 =< -10, - -24*X62 +X124 =< 0, - +X2 +8.33E-4*X73 +8.3E-5*X96 =< 1, - -X89 =< -20, - -X80 -X125 =< -500, - +X18 +8.33E-4*X89 +8.3E-5*X112 =< 2, - +X7 +8.33E-4*X78 +8.3E-5*X101 =< 2, - -X82 +X83 =< -50, - -24*X65 +X127 =< 0, - -672*X34 -1344*X50 -X107 +X128 =< 0, - -X15 +X16 =< 0, - +X11 +8.33E-4*X82 +8.3E-5*X105 =< 1, - -X3 +X4 =< 0, - -X117 =< 0, - -X92 -X133 =< -200, - +X21 +8.33E-4*X92 +8.3E-5*X115 =< 2, - -672*X25 -1344*X41 -X96 +X97 +X119 =< 0, - -20*X5 +X28 +X44 =< 0, - -X8 +X9 =< 0 - }, - attach_name(X72,'a1'), - attach_name(X81,'a10'), - attach_name(X82,'a11'), - attach_name(X83,'a12'), - attach_name(X84,'a13'), - attach_name(X85,'a14'), - attach_name(X86,'a15'), - attach_name(X87,'a16'), - attach_name(X88,'a17'), - attach_name(X89,'a18'), - attach_name(X90,'a19'), - attach_name(X73,'a2'), - attach_name(X91,'a20'), - attach_name(X92,'a21'), - attach_name(X93,'a22'), - attach_name(X94,'a23'), - attach_name(X74,'a3'), - attach_name(X75,'a4'), - attach_name(X76,'a5'), - attach_name(X77,'a6'), - attach_name(X78,'a7'), - attach_name(X79,'a8'), - attach_name(X80,'a9'), - attach_name(X95,'b1'), - attach_name(X104,'b10'), - attach_name(X105,'b11'), - attach_name(X106,'b12'), - attach_name(X107,'b13'), - attach_name(X108,'b14'), - attach_name(X109,'b15'), - attach_name(X110,'b16'), - attach_name(X111,'b17'), - attach_name(X112,'b18'), - attach_name(X113,'b19'), - attach_name(X96,'b2'), - attach_name(X114,'b20'), - attach_name(X115,'b21'), - attach_name(X116,'b22'), - attach_name(X117,'b23'), - attach_name(X97,'b3'), - attach_name(X98,'b4'), - attach_name(X99,'b5'), - attach_name(X100,'b6'), - attach_name(X101,'b7'), - attach_name(X102,'b8'), - attach_name(X103,'b9'), - attach_name(X1,'c1'), - attach_name(X10,'c10'), - attach_name(X11,'c11'), - attach_name(X12,'c12'), - attach_name(X13,'c13'), - attach_name(X14,'c14'), - attach_name(X15,'c15'), - attach_name(X16,'c16'), - attach_name(X17,'c17'), - attach_name(X18,'c18'), - attach_name(X19,'c19'), - attach_name(X2,'c2'), - attach_name(X20,'c20'), - attach_name(X21,'c21'), - attach_name(X22,'c22'), - attach_name(X23,'c23'), - attach_name(X3,'c3'), - attach_name(X4,'c4'), - attach_name(X5,'c5'), - attach_name(X6,'c6'), - attach_name(X7,'c7'), - attach_name(X8,'c8'), - attach_name(X9,'c9'), - attach_name(X24,'d1'), - attach_name(X32,'d10'), - attach_name(X33,'d12'), - attach_name(X34,'d13'), - attach_name(X35,'d15'), - attach_name(X36,'d16'), - attach_name(X37,'d17'), - attach_name(X25,'d2'), - attach_name(X38,'d20'), - attach_name(X39,'d21'), - attach_name(X26,'d3'), - attach_name(X27,'d4'), - attach_name(X28,'d5'), - attach_name(X29,'d6'), - attach_name(X30,'d7'), - attach_name(X31,'d9'), - attach_name(X118,'f1'), - attach_name(X126,'f10'), - attach_name(X127,'f12'), - attach_name(X128,'f13'), - attach_name(X129,'f15'), - attach_name(X130,'f16'), - attach_name(X131,'f17'), - attach_name(X119,'f2'), - attach_name(X132,'f20'), - attach_name(X133,'f21'), - attach_name(X120,'f3'), - attach_name(X121,'f4'), - attach_name(X122,'f5'), - attach_name(X123,'f6'), - attach_name(X124,'f7'), - attach_name(X125,'f9'), - attach_name(X56,'g1'), - attach_name(X64,'g10'), - attach_name(X65,'g12'), - attach_name(X66,'g13'), - attach_name(X67,'g15'), - attach_name(X68,'g16'), - attach_name(X69,'g17'), - attach_name(X57,'g2'), - attach_name(X70,'g20'), - attach_name(X71,'g21'), - attach_name(X58,'g3'), - attach_name(X59,'g4'), - attach_name(X60,'g5'), - attach_name(X61,'g6'), - attach_name(X62,'g7'), - attach_name(X63,'g9'), - attach_name(X40,'h1'), - attach_name(X48,'h10'), - attach_name(X49,'h12'), - attach_name(X50,'h13'), - attach_name(X51,'h15'), - attach_name(X52,'h16'), - attach_name(X53,'h17'), - attach_name(X41,'h2'), - attach_name(X54,'h20'), - attach_name(X55,'h21'), - attach_name(X42,'h3'), - attach_name(X43,'h4'), - attach_name(X44,'h5'), - attach_name(X45,'h6'), - attach_name(X46,'h7'), - attach_name(X47,'h9'), - true. - -example( bell3a_nonred, Min, Vs, Ints, Bins) :- - Bins = [], - Ints = [X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15,X16,X17,X18,X19,X20,X21,X22,X23,X24,X25,X26,X27,X28,X29,X30,X31,X32,X33,X34,X35,X36,X37,X38,X39,X40,X41,X42,X43,X44,X45,X46,X47,X48,X49,X50,X51,X52,X53,X54,X55,X56,X57,X58,X59,X60,X61,X62,X63,X64,X65,X66,X67,X68,X69,X70,X71], - Min = 43000*X24+43000*X25+43000*X26+43000*X27+43000*X28+43000*X29+43000*X30+43000*X31+43000*X32+43000*X33+43000*X34+43000*X35+43000*X36+44000*X37+43000*X38+43000*X39+58000*X40+58000*X41+58000*X42+58000*X43+58000*X44+58000*X45+59000*X46+60000*X47+59000*X48+59000*X49+59000*X50+59000*X51+59000*X52+60000*X53+59000*X54+59000*X55+10000*X56+10000*X57+10000*X58+10000*X59+10000*X60+10000*X61+10000*X62+10000*X63+10000*X64+10000*X65+10000*X66+10000*X67+10000*X68+10000*X69+10000*X70+10000*X71+12.775*X72+16.425*X73+18.25*X74+21.17*X75+18.98*X76+14.6*X77+36.5*X78+73*X79+73*X80+18.25*X81+10.95*X82+21.9*X83+51.1*X84+10.585*X85+80.8475*X86+88.5125*X87+95.63*X88+25.55*X89+14.6*X90+58.4*X91+73*X92+21.9*X93+0.073*X94+1.2775*X95+1.6425*X96+1.825*X97+2.117*X98+1.898*X99+1.46*X100+3.65*X101+7.3*X102+7.3*X103+1.825*X104+1.095*X105+2.19*X106+5.11*X107+1.0585*X108+8.08475*X109+8.85125*X110+9.563*X111+2.555*X112+1.46*X113+5.84*X114+7.3*X115+2.19*X116+0.0073*X117, - Vs = [X1,X10,X100,X101,X102,X103,X104,X105,X106,X107,X108,X109,X11,X110,X111,X112,X113,X114,X115,X116,X117,X118,X119,X12,X120,X121,X122,X123,X124,X125,X126,X127,X128,X129,X13,X130,X131,X132,X133,X14,X15,X16,X17,X18,X19,X2,X20,X21,X22,X23,X24,X25,X26,X27,X28,X29,X3,X30,X31,X32,X33,X34,X35,X36,X37,X38,X39,X4,X40,X41,X42,X43,X44,X45,X46,X47,X48,X49,X5,X50,X51,X52,X53,X54,X55,X56,X57,X58,X59,X6,X60,X61,X62,X63,X64,X65,X66,X67,X68,X69,X7,X70,X71,X72,X73,X74,X75,X76,X77,X78,X79,X8,X80,X81,X82,X83,X84,X85,X86,X87,X88,X89,X9,X90,X91,X92,X93,X94,X95,X96,X97,X98,X99], - { - X63-1/24*X125>=0, - X93+1000000/833*X22+83/833*X116=<13000000/833, - X56-1/24*X118>=0, - X47+1/2*X31-1/1344*X125+1/1344*X103>=0, - X85+1000000/833*X14+83/833*X108=<2000000/833, - X58-1/24*X120>=0, - X40+X24-20*X1=<0, - X69-1/24*X131>=0, - X60-1/24*X122>=0, - X70-1/24*X132>=0, - X98-X97-1344*X42-672*X26+X120=<0, - X57-1/24*X119>=0, - X99+1344*X44+672*X28-X122-X109-X104-X100>=0, - X20-X19=<0, - X71-1/24*X133>=0, - X89+1000000/833*X18+83/833*X112=<2000000/833, - X97-X96-1344*X41-672*X25+X119=<0, - X1>=0, - X1=<1, - X100>=0, - X101>=0, - X103>=0, - X104>=0, - X106>=0, - X107>=0, - X108>=0, - X109>=0, - X110>=0, - X111>=0, - X112>=0, - X114>=0, - X115>=0, - X116>=0, - X117>=0, - X118>=0, - X119>=0, - X120>=0, - X121>=0, - X122>=0, - X125>=0, - X127>=0, - X128>=0, - X131>=0, - X132>=0, - X133>=0, - X24>=0, - X24=<1, - X25>=0, - X25=<1, - X26>=0, - X26=<1, - X27>=0, - X27=<1, - X28>=0, - X28=<1, - X29>=0, - X29=<1, - X30>=0, - X30=<1, - X31>=0, - X31=<1, - X32>=0, - X32=<1, - X33>=0, - X33=<1, - X34>=0, - X34=<1, - X35>=0, - X35=<1, - X36>=0, - X36=<1, - X37>=0, - X37=<1, - X38>=0, - X38=<1, - X39>=0, - X39=<1, - X56>=0, - X56=<1000, - X57>=0, - X57=<1000, - X58>=0, - X58=<1000, - X59>=0, - X59=<1000, - X60>=0, - X60=<1000, - X61>=0, - X61=<1000, - X62>=0, - X62=<1000, - X63>=0, - X63=<1000, - X64>=0, - X64=<1000, - X65>=0, - X65=<1000, - X66>=0, - X66=<1000, - X67>=0, - X67=<1000, - X68>=0, - X68=<1000, - X69>=0, - X69=<1000, - X70>=0, - X70=<1000, - X71>=0, - X71=<1000, - X74>=0, - X75>=0, - X85>=300, - X89>=20, - X93>=100, - X94>=50, - X95>=0, - X97>=0, - X98>=0, - X99>=0, - X84>=0, - X83>=0, - X87>=0, - X86>=0, - X88>=0, - X81>=0, - X76>=0, - X77>=0, - X73>=0, - X72>=0, - X96>=0, - X130>=0, - X129>=0, - X14>=0, - X18>=0, - X22>=0, - X23>=0, - X41>=0, - X44>=0, - X47>=0, - X46>=0, - X43>=0, - X20>=0, - X54>=0, - X40>=0, - X91+X132>=600, - X114-X113=<0, - X91>=0, - X42>=0, - X82+1000000/833*X11+83/833*X105=<1000000/833, - X85+X82-X81-X126=<0, - X64-1/24*X126>=0, - X106-X105=<0, - X126>=0, - X19>=0, - X80+X125>=500, - X9-X8=<0, - X92+X133>=200, - X62-1/24*X124>=0, - X7-X6=<0, - X55+1/2*X39-1/1344*X133+1/1344*X115>=0, - X103-X102=<0, - X6-1/20*X45-1/20*X29>=0, - X55>=0, - X80>=0, - X61-1/24*X123>=0, - X78>=0, - X123>=0, - X7-1/20*X46-1/20*X30>=0, - X124>=0, - X92>=0, - X50>=0, - X49>=0, - X45>=0, - X53>=0, - X52>=0, - X51>=0, - X48>=0, - X99-X98-1344*X43-672*X27+X121=<0, - X76-X75-X121=< -10, - X59-1/24*X121>=0, - X84-X83-X127=< -160, - X65-1/24*X127>=0, - X49+1/2*X33-1/1344*X127-1/1344*X107+1/1344*X106>=0, - X84+X128>=100, - X50+1/2*X34-1/1344*X128+1/1344*X107>=0, - X66-1/24*X128>=0, - X92+1000000/833*X21+83/833*X115=<2000000/833, - X75-X74-X120=< -200, - X5-1/20*X44-1/20*X28>=0, - X42-20*X3+X26=<0, - X88+1000000/833*X17+83/833*X111=<2000000/833, - X81+83/833*X104+1000000/833*X10=<13000000/833, - X2-X1=<0, - X99+833/83*X76+1000000/83*X5=<1000000/83, - X14-X10=<0, - X87+1000000/833*X16+83/833*X110=<2000000/833, - X88-X87-X130=< -150, - X6-X23>=0, - X86+1000000/833*X15+83/833*X109=<2000000/833, - X53+1/2*X37-1/1344*X131-1/1344*X112+1/1344*X111>=0, - X68-1/24*X130>=0, - X87-X86-X129=< -100, - X6-X22>=0, - X6-X19>=0, - X77+1000000/833*X6+83/833*X100=<13000000/833, - X18-X17=<0, - X67-1/24*X129>=0, - X43-20*X4+X27=<0, - X98+833/83*X75+1000000/83*X4=<1000000/83, - X41+X25-20*X2=<0, - X84+1000000/833*X13+83/833*X107=<2000000/833, - X96-X95-1344*X40-672*X24+X118=<0, - X8-X7=<0, - X74-X73-X119=< -50, - X97+833/83*X74+1000000/83*X3=<2000000/83, - X54+X38-20*X20=<0, - X54+1/2*X38-1/1344*X132+1/1344*X114>=0, - X7-X21>=0, - X55+X39-20*X21=<0, - X89-X88-X131=< -10, - X4-X3=<0, - X90+1000000/833*X19+83/833*X113=<1000000/833, - X91-X90=<0, - X86+X81+X77-X76-X122=<0, - X95+833/83*X72+1000000/83*X1=<2000000/83, - X73-X72-X118=< -100, - X46+1/2*X30-1/1344*X124-1/1344*X115-1/1344*X102+1/1344*X101>=0, - X83-X82=< -50, - X8+833/1000000*X79+83/1000000*X102=<1, - X80-X79=< -10, - X96+833/83*X73+1000000/83*X2=<1000000/83, - X3-X2=<0, - X50+X34-20*X13=<0, - X78+1000000/833*X7+83/833*X101=<2000000/833, - X45+1/2*X29-1/1344*X123-1/1344*X117-1/1344*X116-1/1344*X113-1/1344*X101+1/1344*X100>=0, - X94+X93+X90+X78-X77-X123=<0, - X49+X33-20*X12=<0, - X6-X5=<0, - X16-X15=<0, - X53+X37-20*X17=<0, - X52+X36-20*X16=<0, - X17-X16=<0, - X52+1/2*X36-1/1344*X130-1/1344*X111+1/1344*X110>=0, - X5-X15>=0, - X51+X35-20*X15=<0, - X51+1/2*X35-1/1344*X129-1/1344*X110+1/1344*X109>=0, - X5-X4=<0, - X5-X10>=0, - X48+X32-20*X10=<0, - X13-X12=<0, - X12-X11=<0, - X11-X10=<0, - X48+1/2*X32-1/1344*X126-1/1344*X108-1/1344*X105+1/1344*X104>=0, - X92+X79-X78-X124=< -150, - X9-1/20*X47-1/20*X31>=0 - }. - -allpos( []). -allpos( [V|Vs]) :- - { V >= 0 }, - allpos( Vs). - -attach_name( _, _). diff --git a/CLPQR/clpqr/examples/monash/README b/CLPQR/clpqr/examples/monash/README deleted file mode 100644 index 7d8847c68..000000000 --- a/CLPQR/clpqr/examples/monash/README +++ /dev/null @@ -1,9 +0,0 @@ -This collection of examples has been distributed with the Monash University -Version of clp(r) [Heintze et al. 87], and its inclusion into this -distribution was kindly permitted by Roland Yap. - -[Heintze et al. 87] - - Heintze N., Jaffar J., Michaylov S., Stuckey P., Yap R.: The CLP(R) - Programmers Manual, Monash University, Clayton, Victoria, Australia, - Department of Computer Science, 1987. diff --git a/CLPQR/clpqr/examples/monash/air b/CLPQR/clpqr/examples/monash/air deleted file mode 100644 index 167fac7de..000000000 --- a/CLPQR/clpqr/examples/monash/air +++ /dev/null @@ -1,129 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Calculate excess air needed for a chemical reaction to proceed in some way -% The goal -% ?- go. -% is a sample reaction. -% - -mol_comp(n2, [f(n, 2)]). -mol_comp(o2, [f(o, 2)]). -mol_comp(co2, [f(c, 1),f(o, 2)]). -mol_comp(co, [f(c, 1),f(o, 1)]). -mol_comp(c, [f(c, 1)]). -mol_comp(h2o, [f(h, 2),f(o, 1)]). - -comp(air, vol, [f(n2, 0.79),f(o2, 0.21)]). -comp(flue, vol, [f(co2, 0.125),f(co, 0.025),f(o2, 0.03),f(n2, 0.82)]). -comp(full_comb, vol, [f(co2, 1),f(n2, T)]). -comp(fuel, vol, [f(c, 1)]). - -basis(1.0). - -bal(LEFT, RIGHT, VARS) :- - bal_side(LEFT, VARS, NEW_VARS), - bal_side(RIGHT, NEW_VARS, N_VARS), - zero(N_VARS). - -zero([]). -zero([f(X, 0)|L]) :- - zero(L). - -bal_side([], [], []). -bal_side([], [f(A, X)| L1], [f(A, MX)| L2]) :- - MX = -X, - bal_side([], L1, L2). -bal_side([f(S,X)| L], VARS, NEW_VARS) :- - comp(S, T, COMP_LIST), - printf("species %s \n",[S]), - add_species(X, COMP_LIST, VARS, N_VARS), - bal_side(L,N_VARS, NEW_VARS). - -add_species(X, [f(SPEC, PROP)| L], VARS, NEW_VARS) :- - printf("molecule %s \n",[SPEC]), - mol_comp(SPEC, ELEMENTS), - add_elements(X, PROP, ELEMENTS, VARS, N_VARS), - add_species(X, L, N_VARS, NEW_VARS). -add_species(X, [], VARS, VARS). - -add_elements(X, PROP, [f(n, NUM)| L], VARS, NEW_VARS) :- - add_elements(X, PROP, L, VARS, NEW_VARS). - -add_elements(X, PROP, [f(E, NUM)| L], [f(E, Z)| VARS], [f(E, Z1)| NEW_VARS]):- - Z = X*PROP*NUM + Z1 , - printf("atom %s \n",[E]), - add_elements(X, PROP, L, VARS, NEW_VARS). - -add_elements(X, PROP, [f(F, NUM)| L], [f(E, Z)| VARS], [f(E, Z)| NEW_VARS]):- - add_elements(X, PROP, [f(F, NUM)| L], VARS, NEW_VARS). - -add_elements(X, PROP, [], VARS, VARS). - -excess(A, A1) :- - B = A - A1, - B = ANS * A1, - PERC = ANS * 100 , - printf("Excess = %f%% \n",[PERC]). - -go:- basis(BASE), - bal([f(air, A),f(fuel, BASE)], [f(flue, F)], [f(c,0),f(o,0)]), - printf("With base of %f mol of fuel\n",[BASE]), - printf("air (just to burn the carbon) = %f mol\n",[A]), - printf("flue (mol) :%f\n",[F]), - nl, - bal([f(air, A1),f(fuel, BASE)], [f(full_comb, F1)], [f(c,0),f(o,0)]), - printf("Compared with theoretical air (for complete combustion):\n",[]), - printf(" %f mol\n",[A1]), - excess(A, A1). - - -% Answer: -% species air -% molecule n2 -% molecule o2 -% atom o -% species fuel -% molecule c -% atom c -% species flue -% molecule co2 -% atom c -% atom o -% molecule co -% atom c -% atom o -% molecule o2 -% atom o -% molecule n2 -% With base of 1.000000 mol of fuel -% air (just to burn the carbon) = 5.317460 mol -% flue (mol) :6.666667 -% -% species air -% molecule n2 -% molecule o2 -% atom o -% species fuel -% molecule c -% atom c -% species full_comb -% molecule co2 -% atom c -% atom o -% molecule n2 -% Compared with theoretical air (for complete combustion): -% 4.761905 mol -% Excess = 11.666667% - - -?- printf("\n>>> Sample goal: go/0\n", []). - diff --git a/CLPQR/clpqr/examples/monash/amplif b/CLPQR/clpqr/examples/monash/amplif deleted file mode 100644 index a768c3ac4..000000000 --- a/CLPQR/clpqr/examples/monash/amplif +++ /dev/null @@ -1,313 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Transistor amplifier design and analysis package. -% The goal -% ?- go1. -% analyses an existing amplifier circuit, while the goal -% ?- go2. -% imposes certain design constraints on an amplifier of -% a certain form and then determines suitable component values, -% by choosing them from a list of available (preffered) components. -% - -/****************************************************************************/ -/* Major goals */ -/****************************************************************************/ -dc_analysis(Vcc1,Vcc2,Circuit):- - solve_dc(mean,Circuit ,[n(cc1,Vcc1,[_]),n(cc2,Vcc2,[_]),n(gnd,0,[_])], - Nodelist,Collector_Currents), - current_solve(Nodelist), - print_value(Nodelist), - print_circuit(Circuit). - -full_analysis(Vcc1,Vcc2,Circuit,In,Out,Type,Stability,Gain,Inresist,Outresist):- - Inresist = -1 / Iin, - Gain = Vout, - Outresist = -1 / Iout, - circuit(Vcc1, Vcc2, Circuit,In, Out,Type), - solve_dc(mean,Circuit ,[n(cc1,Vcc1,[_]), n(cc2,Vcc2,[_]), n(gnd,0,[_])], - Nodelist,Collector_Currents), - current_solve(Nodelist), - %print_value(Nodelist), - stability(Vcc1,Vcc2,Circuit,Collector_Currents,Stability), - printf("Stab %\n",[Stability]), - solve_ss(Circuit,Collector_Currents, - [n(cc1,0,[_]),n(cc2,0,[_]),n(gnd,0,[_]), - n(In,1,[Iin]),n(Out,Vout,[])],Nodelist2), - current_solve(Nodelist2), - %print_value(Nodelist2), - solve_ss(Circuit,Collector_Currents, - [n(cc1,0,[_]),n(cc2,0,[_]),n(gnd,0,[_]), - n(Out,1,[Iout])],Nodelist3), - %print_value(Nodelist3), - current_solve(Nodelist3), - %print_value(Nodelist3), - printf("Outresist % \n",[Outresist]), - print_circuit(Circuit). - -/****************************************************************************/ -/* small signal equivalent solve */ -/****************************************************************************/ -solve_ss([],[], List,List). -solve_ss([[Component,_,Data,Points]|Rest],CCin,Innodes,Outnodes):- - connecting(Points,Volts,Amps,Innodes,Tmpnodes), - component_ss(Component,Data,Volts,Amps,CCin,CCout), - solve_ss(Rest,CCout,Tmpnodes,Outnodes). - -component_ss(resistor,R,[V1,V2],[I,-1*I],Cc,Cc):- - V1-V2 = R*I, - resistor_val(R). -component_ss(capacitor,_,[V,V],[I,-1*I],Cc,Cc). -component_ss(transistor,[npn,Code,active],[Vb,Vc,Ve], [Ib,Ic,Ie],[Icol|CC],CC):- - Vb - Ve = (Beta * Vt / Icol) * Ib, - Ic = Beta * Ib, - Ie + Ic + Ib = 0, - transistor_type(Type,Code,Beta,_,_,Vt,mean). - - -/****************************************************************************/ -/* dc component solving */ -/****************************************************************************/ -solve_dc(_, [], List, List, []). -solve_dc(Kind,[[Component,_,Data,Points] | Rest], Inlist,Outlist,CCin):- - connecting(Points, Volts, Amps, Inlist,Tmplist), - component_dc(Component,Data,Volts,Amps,CCin,CCout,Kind), - solve_dc(Kind, Rest, Tmplist,Outlist,CCout). - -component_dc(resistor,R,[V1,V2],[I,-1*I],Cc,Cc,_):- - V1-V2 = R*I, - resistor_val(R). -component_dc(capacitor,_,[V1,V2],[0,0],Cc,Cc,_). -component_dc(transistor,[Type,Code,State],Volts, [Ib,Ic,Ie],[Ic|CC],CC,Kind):- - transistor_type(Type,Code,Beta,Vbe,Vcesat,_,Kind), - transistor_state(Type,State,Beta,Vbe,Vcesat,Volts,[Ib,Ic,Ie]). -component_dc(diode,[Code,State],Volts,Amps,Cc,Cc,_):- - diode_type(Code,Vf,Vbreak), - diode_state(State,Vf,Vreak,Volts,Amps). - -/****************************************************************************/ -/* diode and transistor states / and relationships */ -/****************************************************************************/ -diode_state(forward,Vf,Vbreak,[Vp,Vm],[I, -1*I]):- - /* forward biased */ - Vp - Vm = Vf, - I >= 0. -diode_state(reverse,Vf,Vbreak,[Vp,Vm],[I, -1*I]):- - /* reverse biased */ - Vp - Vm < Vf, - Vm - Vp < Vbreak, - I = 0. - -transistor_state(npn, active, Beta, Vbe,_,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb = Ve + Vbe, - Vc >= Vb, - Ib >= 0, - Ic = Beta*Ib, - Ie+Ib+Ic = 0. -transistor_state(pnp, active, Beta, Vbe,_,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb = Ve + Vbe, - Vc <= Vb, - Ib <= 0, - Ic = Beta*Ib, - Ie+Ib+Ic = 0. -transistor_state(npn, saturated, Beta, Vbe, Vcesat,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb = Ve + Vbe, - Vc = Ve + Vcesat, - Ib >= 0, - Ic >= 0, - Ie+Ib+Ic = 0. -transistor_state(pnp, saturated, Beta, Vbe, Vcesat,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb = Ve + Vbe, - Vc = Ve + Vcesat, - Ib <= 0, - Ic <= 0, - Ie+Ib+Ic = 0. -transistor_state(npn, cutoff, Beta, Vbe, Vcesat,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb <= Ve + Vbe, - Ib = 0, - Ic = 0, - Ie = 0. -transistor_state(pnp, cutoff, Beta, Vbe, Vcesat,[Vb, Vc, Ve], [Ib, Ic, Ie]):- - Vb >= Ve + Vbe, - Ib = 0, - Ic = 0, - Ie = 0. - -/****************************************************************************/ -/* connecting components routines */ -/****************************************************************************/ -connecting([],[],[],List,List). -connecting([P|PR],[V|VR],[I|IR], Inlist,Outlist):- - connect(P,V,I,Inlist,Tmplist), - connecting(PR,VR,IR,Tmplist,Outlist). - -connect(P,V,I,[],[n(P,V,[I])]):-!. -connect(P,V,I, [n(P,V,Ilist) | Rest],[n(P,V,[I|Ilist])|Rest]):-!. -connect(P,V,I, [A|Rest], [A|Newrest]) :- - connect(P,V,I, Rest, Newrest). - -/****************************************************************************/ -/* Stability Analysis */ -/****************************************************************************/ -stability(Vcc1,Vcc2,Circuit, CollectorCurrents, Stability):- - solve_dc(minn,Circuit ,[n(cc1,Vcc1,[_]),n(cc2,Vcc2,[_]),n(gnd,0,[_])], - Nodelist1,MinCurrents), - current_solve(Nodelist1), - % printf(" Min %\n Minmodes \n",[MinCurrents]), - % print_value(Nodelist1), - solve_dc(maxx,Circuit ,[n(cc1,Vcc1,[_]),n(cc2,Vcc2,[_]),n(gnd,0,[_])], - Nodelist2,MaxCurrents), - current_solve(Nodelist2), - % printf(" Max %\n Maxnodes\n",[MaxCurrents]), - % print_value(Nodelist2), - calculate(MinCurrents,MaxCurrents,CollectorCurrents,Stability). - -calculate(MinCurrents,MaxCurrents,CollectorCurrents,Stability):- - cal(MinCurrents,MaxCurrents,CollectorCurrents,Percents), - % printf(" Percent % \n",[Percents]), - maxi(Percents,0,Stability). - -cal([Min|Rin],[Max|Rax],[Ic|Rc],[Pc|Rpc]):- - Pc=max(Ic-Min,Max-Ic), - cal(Rin,Rax,Rc,Rpc). -cal([],[],[],[]). - -maxi([N1|R],N2,P):- - M=max(N1,N2), - maxi(R,M,P). -maxi([],P,P). -/****************************************************************************/ -/* Miscellaneous things */ -/****************************************************************************/ -current_solve([]). -current_solve([n(_,_,L) | Rest]) :- - kcl(L), - current_solve(Rest). - -print_value([]). -print_value([n(P,V,I) | Rest]) :- - printf("% at % %\n",[P,V,I]), - print_value(Rest). - -print_circuit([]). -print_circuit([[Comp,Name,Data,Points] | Rest]) :- - printf(" % at % %\n",[Comp,Name,Data]), - print_circuit(Rest). - -sum([X|T],Z) :- - X+P = Z, - sum(T,P). -sum([],0). - -kcl(L) :- - sum(L,0). - -/****************************************************************************/ -/* Database of circuits and components */ -/****************************************************************************/ -resistor_val(100). -resistor_val(50). -resistor_val(27). -resistor_val(5). -resistor_val(2). -resistor_val(1). - -diode_type(di1, 0.6, 100). - -transistor_type(npn, tr0, 100, 0.7, 0.3, 0.025,mean). -transistor_type(npn, tr0, 50, 0.8, 0.3, 0.025,minn). -transistor_type(npn, tr0, 150, 0.6, 0.3, 0.025,maxx). - -transistor_type(pnp, tr1, 100, -0.7, -0.3, 0.025,mean). -transistor_type(pnp, tr1, 50, -0.8, -0.3, 0.025,minn). -transistor_type(pnp, tr1, 150, -0.6, -0.3, 0.025,maxx). - -circuit(15,0,[ - [capacitor,c1,c1,[in,b]], - [resistor,r1,R1,[b,cc1]], - [resistor,r2,R2,[b,gnd]], - [transistor,tr,[npn,tr0,active],[b,c,e]], - [resistor,re,Re,[e,gnd]], - [capacitor,c2,c2,[c,out]], - [resistor,rc,Rc,[c,cc1]], - [capacitor,c3,c3,[e,gnd]]], - in,out,common_emitter). - -circuit(15,0,[ - [capacitor,c1,C1,[gnd,b]], - [resistor,r1,R1,[b,cc1]], - [resistor,r2,R2,[b,gnd]], - [transistor,tr,[pnp,tr1,active],[b,c,e]], - [resistor,re,Re,[e,gnd]], - [capacitor,c2,C2,[c,in]], - [resistor,rc,Rc,[c,cc1]], - [capacitor,c3,C3,[e,out]]], - in,out,common_base). - -circuit(15,0,[ - [capacitor,c1,C1,[in,b]], - [resistor,r1,R1,[b,cc1]], - [resistor,r2,R2,[b,gnd]], - [transistor,tr,[npn,tr0,active],[b,cc1,e]], - [resistor,re,Re,[e,gnd]], - [capacitor,c3,C3,[e,out]]], - in,out,emitter_follower). - -go1:- dc_analysis(15,-12,[ - [diode,d1,[di1,St1],[a,gnd]], - [diode,d2,[di1,St2],[a,cc1]], - [resistor,r1,100,[a,cc1]], - [diode,d3,[di1,St3],[a,p1]], - [diode,d4,[di1,St4],[p1,b]], - [resistor,r2,100,[b,cc2]], - [transistor,tr,[npn,tr0,State],[b,c,gnd]], - [resistor,rc,100,[c,cc1]]]). - -% Answer: -% cc1 at 15 [0, 0.144, 0, -0.144] -% cc2 at -12 [-0.114, 0.114] -% gnd at 0 [0, -0.03, 0.03] -% a at 0.6 [0.114, -0.144, 0, 0.03] -% p1 at 0 [0.114, -0.114] -% b at -0.6 [0, 0.114, -0.114] -% c at 15 [0, 0] -% diode at d1 [di1, forward] -% diode at d2 [di1, reverse] -% resistor at r1 100 -% diode at d3 [di1, forward] -% diode at d4 [di1, forward] -% resistor at r2 100 -% transistor at tr [npn, tr0, cutoff] -% resistor at rc 100 - -go2:- -Vcc = 15, Stability < 0.5, Gain > 0.5, - Inresistance >= 25, Outresistance <= 2, - full_analysis(Vcc, _, Circuit, _, _, emitter_follower, Stability, - Gain, Inresistance, Outresistance), - write(Circuit),nl. - -% Answer: -% Stab 0.001947 -% Outresist 0.857107 -% capacitor at c1 Data_48 -% resistor at r1 100 -% resistor at r2 100 -% transistor at tr [npn, tr0, active] -% resistor at re 100 -% capacitor at c3 Data_52 -% [[capacitor, c1, C1_48, [in, b]], [resistor, r1, 100, [b, cc1]], -% [resistor, r2, 100, [b, gnd]], [transistor, tr, [npn, tr0, active], -% [b, cc1, e]], [resistor, re, 100, [e, gnd]], [capacitor, c3, C3_52, -% [e, out]]] - -?- printf("\n>>> Sample goals: go1/0, go2/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/complex b/CLPQR/clpqr/examples/monash/complex deleted file mode 100644 index 47465cf9f..000000000 --- a/CLPQR/clpqr/examples/monash/complex +++ /dev/null @@ -1,41 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% The rule below describes the relationship between two complex numbers -% and their product. The goal ?- go uses the rule -% first to multiply two complex numbers, and then to divide one by another, -% in two different ways. -% - -zmul(c(R1,I1),c(R2,I2),c(R3,I3)) :- - R3 = R1 * R2 - I1 * I2 , - I3 = R1 * I2 + R2 * I1 . - -go :- zmul(c(1,1),c(2,2),Z), - zmul(c(1,1),Y,c(0,4)), - zmul(X,c(2,2),c(0,4)), - nl, - write(" X = "), - write(X), - nl, - write(" Y = "), - write(Y), - nl, - write(" Z = "), - write(Z), - nl. - -% Answer: -% X = c(1, 1) -% Y = c(2, 2) -% Z = c(0, 4) - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/critical b/CLPQR/clpqr/examples/monash/critical deleted file mode 100644 index e407e553f..000000000 --- a/CLPQR/clpqr/examples/monash/critical +++ /dev/null @@ -1,318 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% cpm critical path routine -% Network is an input project network of the form -% [ [node1 , node2, time ] .... ] -% Graph is the critical path graph produced -% Latest is the latest possible completion time is specified -% cpm/3 is used if the latest time is specified -% otherwise use cpm/2 -% - -% Explanation of output -/* - Node Es Lc (Gives the Earliest Start time and Latest Completion - time for the particular node) -Node1 Node2 T Ls Ec Tf Ff -(Details the times relating to the activity between Node1 & Node2 - T is the time required for the activity - Ls the Latest Start time - Ec the Earliest Completion time - Tf the Total Float - Ff the Free Float) - Activities on the critical path are marked with an asterix - The start node and end node are computed automatically and distinguished -*/ - -% Sample output -/* - Node Es Lc -Node1 Node2 T Ls Ec Tf Ff --------------------------------------------------- -START NODE n1 0 0 --------------------------------------------------- -n1 n2 3 2 3 2 0 -n1 n3 2 0 2 0 0 * --------------------------------------------------- - n2 3 5 --------------------------------------------------- -n2 n4 2 5 5 2 2 --------------------------------------------------- - n3 2 2 --------------------------------------------------- -n3 n4 5 2 7 0 0 * --------------------------------------------------- -END NODE n4 7 7 -*/ - -cpm(Network,Graph,Latest) :- - build(Network,Graph), - early_late(Graph,Graph,End,Latest), - Latest >= End, - analyse(Graph,Graph). - -cpm(Network,Graph) :- - build(Network,Graph), - early_late(Graph,Graph,End), - analyse(Graph,Graph). - -% build an adjacency graph out of the network -build([],Graph) :- - buildv([],_,Graph). -build([[I,J,C]|T],Graph) :- - buildv(ed(I,J,C),to,Graph), - buildv(ed(I,J,C),from,Graph), - build(T,Graph). - -buildv([],_,[]) :- !. -buildv([],_,[ad(_,_,_,To,From)|T]) :- - !,addedg([],_,To), - addedg([],_,From), - buildv([],_,T). -buildv(ed(I,J,C),to,[ad(I,Es,Lc,To,From)|T]) :- - !,addedg(J,C,To). -buildv(Edge,to,[H|T]) :- - !,buildv(Edge,to,T). -buildv(ed(I,J,C),from,[ad(J,Es,Lc,To,From)|T]) :- - !,addedg(I,C,From). -buildv(Edge,from,[H|T]) :- - !,buildv(Edge,from,T). - -addedg([],_,[]) :- !. -addedg([],_,[H|T]) :- !, - addedg([],_,T). -addedg(V,C,[ed(V,C,_,_,_,_)|T]) :- !. -addedg(V,C,[H|T]) :- - addedg(V,C,T). - -% Get early start times and latest completion times -% early/4 is used when a ending time is given -% otherwise early/3 assumes that the early start time -% for the end node is equal to the latest completion time -early_late([],_,_,_). -early_late([ad(I,Es,Lc,To,From)|T],G,End,Latest) :- - setearly(From,To,G,End,Es), - setlate(To,G,Latest,Lc), - early_late(T,G,End,Latest). - -early_late([],_,_). -early_late([ad(I,Es,Lc,To,From)|T],G,End) :- - setearly(From,To,G,End,Es), - setlate(To,G,End,Lc), - early_late(T,G,End). - -setearly([],_,_,_,0). -setearly([ed(V,C,_,_,_,_)|T],[],G,Es,Es) :- - !, - getnode(V,G,Es1,_), - setmax(T,G,Es1+C,Es). -setearly([ed(V,C,_,_,_,_)|T],_,G,End,Es) :- - getnode(V,G,Es1,_), - setmax(T,G,Es1+C,Es). - -setmax([],_,Max,Max). -setmax([ed(V,C,_,_,_,_)|T],G,Max0,Max) :- - getnode(V,G,Es1,_), - setmax(T,G,max(Max0,Es1+C),Max). - -setlate([],_,Last,Last). -setlate([ed(V,C,_,_,_,_)|T],G,Last,Lc) :- - getnode(V,G,_,Lc1), - setmin(T,G,Lc1-C,Lc). - -setmin([],_,Min,Min). -setmin([ed(V,C,_,_,_,_)|T],G,Min0,Min) :- - getnode(V,G,_,Lc1), - setmin(T,G,min(Min0,Lc1-C),Min). - -% Search graph for the early & late times for a node -getnode(I,[ad(I,Es,Lc,_,_)|T],Es,Lc). -getnode(I,[H|T],Es,Lc) :- - getnode(I,T,Es,Lc). - -% Compute the other times : -% Ls - latest start time -% Ec - earliest completion time -% Tf - total float time -% Ff - free float time -analyse([],G). -analyse([ad(I,Es,Lc,To,_)|T],G) :- - analyse_times(To,Es,Lc,G), - analyse(T,G). - -analyse_times([],_,_,_). -analyse_times([ed(V,C,Ls,Ec,Tf,Ff)|T],Esi,Lci,G) :- - getnode(V,G,Esj,Lcj), - compute(Ls,Ec,Tf,Ff,Esj,Lcj,Esi,Lci,C), - analyse_times(T,Esi,Lci,G). - -% Indirect way of doing the calculation just to speed things up -% can be removed and inserted directly in analyse_times -compute(Ls,Ec,Tf,Ff,Esj,Lcj,Esi,Lci,C) :- - X = Esi+C, - Ls = Lcj-C, - Ec = Esi+C, - Tf = Lcj-X, - Ff = Esj-X. - -% display routines -print_analysis(G) :- - printf("\t\tNode\tEs\tLc\n",[]), - printf("Node1\tNode2\tT\tLs\tEc\tTf\tFf\n",[]), - print_analysis1(G). -print_analysis1([]). -print_analysis1([H|T]) :- - print_node(H), - print_analysis1(T). -print_node(ad(I,Es,Lc,[],From)) :- - !, - printf("--------------------------------------------------\n",[]), - printf("END NODE\t%\t%\t%\n",[I,Es,Lc]). -print_node(ad(I,Es,Lc,To,[])) :- - !, - printf("--------------------------------------------------\n",[]), - printf("START NODE\t%\t%\t%\n",[I,Es,Lc]), - printf("--------------------------------------------------\n",[]), - print_times(To,I). -print_node(ad(I,Es,Lc,To,From)) :- - printf("--------------------------------------------------\n",[]), - printf("\t\t%\t%\t%\n",[I,Es,Lc]), - printf("--------------------------------------------------\n",[]), - print_times(To,I). - -print_times([],_). -print_times([ed(V,C,Ls,Ec,Tf,Ff)|T],I) :- - printf("%\t%\t%\t%\t%\t%\t%",[I,V,C,Ls,Ec,Tf,Ff]), - is_critical(Tf), - print_times(T,I). - -is_critical(0) :- - printf(" *\n",[]). -is_critical(Tf) :- - Tf > 0, - printf("\n",[]). - -go1 :- cpm([ - [n1,n2,3],[n1,n3,2],[n3,n4,5],[n2,n4,2]],G), - print_analysis(G). - -% Answer: -% Node Es Lc -% Node1 Node2 T Ls Ec Tf Ff -% -------------------------------------------------- -% START NODE n1 0 0 -% -------------------------------------------------- -% n1 n2 3 2 3 2 0 -% n1 n3 2 0 2 0 0 * -% -------------------------------------------------- -% n2 3 5 -% -------------------------------------------------- -% n2 n4 2 5 5 2 2 -% -------------------------------------------------- -% n3 2 2 -% -------------------------------------------------- -% n3 n4 5 2 7 0 0 * -% -------------------------------------------------- -% END NODE n4 7 7 - -go2 :- cpm([ - [n5,n6,9],[n5,n7,5],[n6,n7,0],[n4,n7,4], - [n1,n2,2],[n2,n3,0],[n1,n3,6],[n1,n4,3], - [n2,n5,1],[n2,n6,4],[n3,n5,2],[n4,n5,0],[n4,n8,3], - [n6,n8,4],[n7,n8,6]],G), - print_analysis(G). - -% Answer: -% Node Es Lc -% Node1 Node2 T Ls Ec Tf Ff -% -------------------------------------------------- -% n5 8 8 -% -------------------------------------------------- -% n5 n6 9 8 17 0 0 * -% n5 n7 5 12 13 4 4 -% -------------------------------------------------- -% n6 17 17 -% -------------------------------------------------- -% n6 n7 0 17 17 0 0 * -% n6 n8 4 19 21 2 2 -% -------------------------------------------------- -% n7 17 17 -% -------------------------------------------------- -% n7 n8 6 17 23 0 0 * -% -------------------------------------------------- -% n4 3 8 -% -------------------------------------------------- -% n4 n7 4 13 7 10 10 -% n4 n5 0 8 3 5 5 -% n4 n8 3 20 6 17 17 -% -------------------------------------------------- -% START NODE n1 0 0 -% -------------------------------------------------- -% n1 n2 2 4 2 4 0 -% n1 n3 6 0 6 0 0 * -% n1 n4 3 5 3 5 0 -% -------------------------------------------------- -% n2 2 6 -% -------------------------------------------------- -% n2 n3 0 6 2 4 4 -% n2 n5 1 7 3 5 5 -% n2 n6 4 13 6 11 11 -% -------------------------------------------------- -% n3 6 6 -% -------------------------------------------------- -% n3 n5 2 6 8 0 0 * -% -------------------------------------------------- -% END NODE n8 23 23 - -go3 :- - cpm([ - [n1,n2,4],[n1,n3,3],[n1,n4,4], [n2,n5,7],[n2,n3,1],[n2,n7,8], - [n3,n5,4], [n4,n6,2], [n5,n6,1],[n5,n7,3], [n6,n7,4]],G), - print_analysis(G). - -% Answer: -% Node Es Lc -% Node1 Node2 T Ls Ec Tf Ff -% -------------------------------------------------- -% START NODE n1 0 0 -% -------------------------------------------------- -% n1 n2 4 0 4 0 0 * -% n1 n3 3 4 3 4 2 -% n1 n4 4 6 4 6 0 -% -------------------------------------------------- -% n2 4 4 -% -------------------------------------------------- -% n2 n5 7 4 11 0 0 * -% n2 n3 1 6 5 2 0 -% n2 n7 8 8 12 4 4 -% -------------------------------------------------- -% n3 5 7 -% -------------------------------------------------- -% n3 n5 4 7 9 2 2 -% -------------------------------------------------- -% n4 4 10 -% -------------------------------------------------- -% n4 n6 2 10 6 6 6 -% -------------------------------------------------- -% n5 11 11 -% -------------------------------------------------- -% n5 n6 1 11 12 0 0 * -% n5 n7 3 13 14 2 2 -% -------------------------------------------------- -% END NODE n7 16 16 -% -------------------------------------------------- -% n6 12 12 -% -------------------------------------------------- -% n6 n7 4 12 16 0 0 * - -?- printf("\n>>> Sample goals: go1/0, go2/0, go3/0\n", []). - diff --git a/CLPQR/clpqr/examples/monash/dnf b/CLPQR/clpqr/examples/monash/dnf deleted file mode 100644 index 4376fe447..000000000 --- a/CLPQR/clpqr/examples/monash/dnf +++ /dev/null @@ -1,175 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Convert a propositional formula into disjunctive normal form. -% There are 15 goals ?- go1 to ?- go 15. -% The goal ?- go5 is the most substantial. -% - -literal(z0). -literal(z1). -literal(z2). -literal(z3). -literal(z4). -literal(z5). -literal(z6). -literal(z7). -literal(z8). -literal(z9). -literal(n(X)) :- literal(X). - -/*---------------------------------------------- base cases ------------------*/ - -norm(X, X) :- literal(X). -norm(o(X, Y), o(X, Y)) :- literal(X), literal(Y). -norm(a(X, Y), a(X, Y)) :- literal(X), literal(Y). - -/*---------------------------------------------- OR cases --------------------*/ - -norm(o(X, Y), o(X1, Y)) :- - literal(Y), - norm(X, X1). -norm(o(X, o(Y, Z)), W) :- - norm(o(o(X, Y), Z), W). -norm(o(X, a(Y1, Y2)), o(X1, Y12)) :- - norm(X, X1), - norm(a(Y1, Y2), Y12). - -/*---------------------------------------------- AND cases -------------------*/ - -norm(a(X, Y), a(X1, Y)) :- - literal(Y), - norm(X, X1). -norm(a(X, a(Y, Z)), W) :- - norm(a(a(X, Y), Z), W). -norm(a(X, o(Y1, Y2)), a(X1, Y12)) :- - norm(X, X1), - norm(o(Y1, Y2), Y12). - -/*----------------------------------------------------------------------------*/ -/*----------------------------------------------------------------------------*/ -/*---------------------------------------------- base cases ------------------*/ - -dnf(X, X) :- literal(X). -dnf(o(X, Y), o(X, Y)) :- literal(X), literal(Y). -dnf(a(X, Y), a(X, Y)) :- literal(X), literal(Y). - -/*---------------------------------------------- compaction ------------------*/ - -dnf(n(n(X)), W) :- dnf(X, W). -dnf(n(o(X, Y)), W) :- dnf(a(n(X), n(Y)), W). -dnf(n(a(X, Y)), W) :- dnf(o(n(X), n(Y)), W). - -/*----------------------------------------------------------------------------*/ - -dnf(o(X, Y), W) :- - dnf(X, X1), - dnf(Y, Y1), - norm(o(X1, Y1), W). -dnf(a(X, Y), a(a(X1, X2), Y)) :- - literal(Y), - dnf(X, a(X1, X2)). -dnf(a(X, Y), a(a(Y1, Y2), X)) :- - literal(X), - dnf(Y, a(Y1, Y2)). -dnf(a(X, Y), W) :- - dnf(X, a(X1, X2)), - dnf(Y, a(Y1, Y2)), - norm(a(a(X1, X2), a(Y1, Y2)), W). -dnf(a(X, Y), W) :- - dnf(X, o(X1, X2)), - dnf(Y, Y1), - dnf(o(a(X1, Y1), a(X2, Y1)), W). -dnf(a(X, Y), W) :- - dnf(X, X1), - dnf(Y, o(Y1, Y2)), - dnf(o(a(X1, Y1), a(X1, Y2)), W). - -go1:- dnf(a(z1, a(z2, o(z3, a(z4, a(z5, z6))))), X), - printf("%\n", [X]). -go2:- dnf(o(o(z1,o(z2,o(z3,z4))),o(z5,o(z6,o(z7,z8)))),X), - printf("%\n", [X]). -go3:- dnf(o(o(a(z1,z2),z3),o(a(z4,a(a(z5,z6),z7)),o(z8,z9))),X), - printf("%\n", [X]). -go4:- dnf(a(a(z1,a(o(z2,z3),z4)),a(z5,o(z6,z7))),X), - printf("%\n", [X]). -go5:- dnf(n(o(a(n(o(z1,z2)),n(a(z3,z4))),a(n(z5),o(a(z6,a(z7,z8)),z9)))),X), - dnf(n(o(a(n(o(z1,z2)),n(a(z3,z4))),a(n(z5),o(a(z6,a(z7,z8)),z9)))),X), - printf("%\n", [X]). -go6:- dnf(n(a(z1,a(z2,z3))),X), - printf("%\n", [X]). -go7:- dnf(a(a(o(z1,z2),z3),z4),X), - printf("%\n", [X]). -go8:- dnf(o(a(z1,z2),a(z3,z4)),X), - printf("%\n", [X]). -go9:- dnf(a(o(z1,z2),o(z3,z4)),X), - printf("%\n", [X]). -go10:- dnf(o(a(o(z1,z2),a(z3,z4)),z5),X), - printf("%\n", [X]). -go11:- dnf(o(o(z1,o(z3,o(z4,a(z4,z5)))),z5),X), - printf("%\n", [X]). -go12:- dnf(o(z1,o(z2,o(z3,z4))),X), - printf("%\n", [X]). -go13:- dnf(o(a(z1,z2),n(o(z2,a(z3,z4)))),X), - printf("%\n", [X]). -go14:- dnf(o(a(n(z0),n(z1)),a(n(z0),n(z2))),X), - printf("%\n", [X]). -go15:- dnf(o(n(a(z1,z2)),a(o(a(o(z1,z2),z3),z4),z5)),X), - printf("%\n", [X]). - -% Answers: -% 1 ?- go1. -% o(a(a(z2, z3), z1), a(a(a(a(z5, z6), z4), z2), z1)) -% -% 2 ?- go2. -% o(o(o(o(o(o(o(z1, z2), z3), z4), z5), z6), z7), z8) -% -% 3 ?- go3. -% o(o(o(o(a(z1, z2), z3), a(a(a(z5, z6), z7), z4)), z8), z9) -% -% 4 ?- go4. -% o(o(o(a(a(a(a(z2, z4), z1), z5), z6), a(a(a(a(z2, z4), z1), z5), z7)), a(a(a(a(z3, z4), z1), z5), z6)), a(a(a(a(z3, z4), z1), z5), z7)) -% -% 5 ?- go5. -% o(o(o(o(o(o(o(o(o(o(o(a(z1, n(n(z5))), a(a(n(z6), n(z9)), z1)), a(a(n(z7), n(z9)), z1)), a(a(n(z8), n(z9)), z1)), a(z2, n(n(z5)))), a(a(n(z6), n(z9)), z2)), a(a(n(z7), n(z9)), z2)), a(a(n(z8), n(z9)), z2)), a(a(z3, z4), n(n(z5)))), a(a(a(z3, z4), n(z6)), n(z9))), a(a(a(z3, z4), n(z7)), n(z9))), a(a(a(z3, z4), n(z8)), n(z9))) -% -% 6 ?- go6. -% o(o(n(z1), n(z2)), n(z3)) -% -% 7 ?- go7. -% o(a(a(z1, z3), z4), a(a(z2, z3), z4)) -% -% 8 ?- go8. -% o(a(z1, z2), a(z3, z4)) -% -% 9 ?- go9. -% o(o(o(a(z1, z3), a(z1, z4)), a(z2, z3)), a(z2, z4)) -% -% 10 ?- go10. -% o(o(a(a(z3, z4), z1), a(a(z3, z4), z2)), z5) -% -% 11 ?- go11. -% o(o(o(o(z1, z3), z4), a(z4, z5)), z5) -% -% 12 ?- go12. -% o(o(o(z1, z2), z3), z4) -% -% 13 ?- go13. -% o(o(a(z1, z2), a(n(z2), n(z3))), a(n(z2), n(z4))) -% -% 14 ?- go14. -% o(a(n(z0), n(z1)), a(n(z0), n(z2))) -% -% 15 ?- go15. -% o(o(o(o(n(z1), n(z2)), a(a(z1, z3), z5)), a(a(z2, z3), z5)), a(z4, z5)) -% - -?- printf("\n>>> Sample goals: go1/0, ..., go15/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/fib b/CLPQR/clpqr/examples/monash/fib deleted file mode 100644 index 8b33ffc34..000000000 --- a/CLPQR/clpqr/examples/monash/fib +++ /dev/null @@ -1,34 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Simple recursive formulation of fibonacci numbers. -% The goal ?- go shows how the definition can be used for -% both finding a a fibonacci number given its index, and finding the index -% of a given fibonacci number. -% - -fib(0, 1). -fib(1, 1). -fib(N, X1 + X2) :- - N > 1, - fib(N - 1, X1), - fib(N - 2, X2). - -go:- fib(10, Z), - printf("forward: fib(10) = %d\n",[Z]), - fib(Y, Z), - printf("backward: fib(%d) = %d\n",[Y,Z]). - -% Answer: -% forward: fib(10) = 89 -% backward: fib(10) = 89 - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/findroot b/CLPQR/clpqr/examples/monash/findroot deleted file mode 100644 index 5113f45de..000000000 --- a/CLPQR/clpqr/examples/monash/findroot +++ /dev/null @@ -1,60 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% This program finds a root of a transcendental function given an initial -% guess. It uses the Steffensen algorithm. -% The goal ?- go finds a root of -% -% 2 -% 1 - X -% -% given X = 1.7 as an initial guess, requiring that the solution give a value -% no more than 0.0000005 from zero. - -getnext(X,NX):- - NX = X - (F / G), - eval(X,F), - getg(X,G). - -getg(X,G):- - G = (FF - F)/F, - eval(X,F), - eval(X+F,FF). - -eval(X,1 - X * X). - -small(X,E):- - X < 0, - (0-X) < E . -small(X,E):- - X >= 0, - X < E . - -solve(I,E):- - eval(I,F), - small(F,E), - printf("%10.8f\n",[I]). -solve(I,E):- - printf("%10.8f\n",[I]), - getnext(I,X), - solve(X,E). - -go:- solve(1.7,0.0000005). - -% Output: -% 1.70000000 -% 0.44834437 -% 0.91953538 -% 0.99701354 -% 0.99999555 -% 1.00000000 - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/invert b/CLPQR/clpqr/examples/monash/invert deleted file mode 100644 index a9d62c552..000000000 --- a/CLPQR/clpqr/examples/monash/invert +++ /dev/null @@ -1,93 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Matrix inversion package. The goal ?- go -% invers a matrix, prints the inverse, then multiplies the two, -% getting the identity matrix, and prints that. -% - - -sizemat(M,R,C):- - mylength(M,R), - allvec(M,C). - -allvec([],C). -allvec([H|T],C):- - mylength(H,C), - allvec(T,C). - -mylength([],0). % length->mylength by ch -mylength([H],1). % to avoid name clash -mylength([H|T],L+1):- - mylength(T,L). - -matmul([H|T],B,[H1|T1]):- - rowmul(H,B,H1), - matmul(T,B,T1). -matmul([],_,[]). - -rowmul(AV,[H|T],[H1|T1]):- - vecmul(AV,H,0,H1), - rowmul(AV,T,T1). -rowmul(_,[],[]). - -vecmul([H1|T1],[H2|T2],IN,OUT):- - TMP = IN + H1 * H2, - vecmul(T1,T2,TMP,OUT). -vecmul([],[],S,S). - -rowtocol(A,[H|T]):- - stripfirst(A,H,REST), - rowtocol(REST,T). -rowtocol(A,[]). - -stripfirst([H|T],[H1|T1],[H2|T2]):- - stripvec(H,H1,H2), - stripfirst(T,T1,T2). -stripfirst([],[],[]). - -stripvec([H|T],H,T). - -putmat([H|T]):- - putvec(H), - putmat(T). -putmat([]). - -putvec([H|T]):- - printf(" %9.4f ",[H]), - putvec(T). -putvec([]):- - nl. - -go:- M = [ [4,5,6], [1,5,3], [1,8,9] ], - I = [ [1,0,0], [0,1,0], [0,0,1] ], - sizemat(N,3,3), - sizemat(NR,3,3), - sizemat(T,3,3), - matmul(M,N,I), - rowtocol(NR,N), - matmul(M,N,T), - printf(" NR = \n",[]), - putmat(NR), - printf(" T = \n",[]), - putmat(T). - -% Output: -% NR = -% 0.2917 0.0417 -0.2083 -% -0.0833 0.4167 -0.0833 -% 0.0417 -0.3750 0.2083 -% T = -% 1.0000 0.0000 0.0000 -% 0.0000 1.0000 0.0000 -% 0.0000 0.0000 1.0000 - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/laplace b/CLPQR/clpqr/examples/monash/laplace deleted file mode 100644 index c4b6922de..000000000 --- a/CLPQR/clpqr/examples/monash/laplace +++ /dev/null @@ -1,89 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Solve the Dirichlet problem for Laplace's equation using -% Leibman's five-point finit-differenc approximation. The goal -% ?- go1 is a normal example, while the goal ?- go2 -% shows output constraints for a small region where the boundary conditions -% are not specified. -% - - -laplace([H1,H2,H3|T]):- - laplace_vec(H1,H2,H3), - laplace([H2,H3|T]). -laplace([_,_]). - -laplace_vec([TL,T,TR|T1],[ML,M,MR|T2],[BL,B,BR|T3]):- - B + T + ML + MR - 4 * M = 0, - laplace_vec([T,TR|T1],[M,MR|T2],[B,BR|T3]). -laplace_vec([_,_],[_,_],[_,_]). - -printmat([H|T]):- - printvec(H), - printmat(T). -printmat([]). - -printvec([H|T]):- - printf("%7.2f",[H]), - printvec(T). -printvec([]):- - printf("\n",[]). - -go1:- - X = [ - [0,0,0,0,0,0,0,0,0,0,0], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,_,_,_,_,_,_,_,_,_,100], - [100,100,100,100,100,100,100,100,100,100,100] - ], - laplace(X), - printf("\n", []), - printmat(X). - -% Answer: -% 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 -% 100.00 51.11 32.52 24.56 21.11 20.12 21.11 24.56 32.52 51.11 100.00 -% 100.00 71.91 54.41 44.63 39.74 38.26 39.74 44.63 54.41 71.91 100.00 -% 100.00 82.12 68.59 59.80 54.97 53.44 54.97 59.80 68.59 82.12 100.00 -% 100.00 87.97 78.03 71.00 66.90 65.56 66.90 71.00 78.03 87.97 100.00 -% 100.00 91.71 84.58 79.28 76.07 75.00 76.07 79.28 84.58 91.71 100.00 -% 100.00 94.30 89.29 85.47 83.10 82.30 83.10 85.47 89.29 94.30 100.00 -% 100.00 96.20 92.82 90.20 88.56 88.00 88.56 90.20 92.82 96.20 100.00 -% 100.00 97.67 95.59 93.96 92.93 92.58 92.93 93.96 95.59 97.67 100.00 -% 100.00 98.89 97.90 97.12 96.63 96.46 96.63 97.12 97.90 98.89 100.00 -% 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 - -go2 :- - laplace([ - [B11, B12, B13, B14], - [B21, M22, M23, B24], - [B31, M32, M33, B34], - [B44, B42, B43, B44] - ]), - printf("\n", []), - dump. - -% Answer: -% B12 = -B21 - 4*B31 + 16*M32 - 8*M33 + B34 - 4*B42 + B43 -% B13 = -B24 + B31 - 8*M32 + 16*M33 - 4*B34 + B42 - 4*B43 -% M22 = -B31 + 4*M32 - M33 - B42 -% M23 = -M32 + 4*M33 - B34 - B43 - -?- printf("\n>>> Sample goals: go1/0, go2/0\n", []). - diff --git a/CLPQR/clpqr/examples/monash/mortgage b/CLPQR/clpqr/examples/monash/mortgage deleted file mode 100644 index cee4f26fe..000000000 --- a/CLPQR/clpqr/examples/monash/mortgage +++ /dev/null @@ -1,55 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Calculate compound interest. -% Arguments are Principal, Time (months), Interest (fraction), Balance, -% and Monthly Payment. -% -% The goals ?- go1 demonstrates -% obtaining ground answers for two different combinations of inputs. -% The goals ?- go2 and ?- go3 deal with getting linear -% equations as answers, while ?- go4 produces a -% polynomial equation. -% - -mg(P,T,I,B,MP):- - T > 0, - T <= 1, - B + MP = P * (1 + I). -mg(P,T,I,B,MP):- - T > 1, - mg(P * (1 + I) - MP, T - 1, I, B, MP). - -go1:- mg(120000,120,0.01,0,MP), printf("Forward: MP = %g\n",[MP]), - mg(P,120,0.01,0,MP), printf("Backward: P = %g\n",[P]). - -% Answer: -% Forward: MP = 1721.651381 -% Backward: P = 120000 - -go2:- mg(P,120,0.01,0,MP), dump([P,MP]). - -% Answer: -% 2 ?- go2. -% P = 69.700522*MP - -go3:- mg(P,120,0.01,B,MP), dump([P,B,MP]). - -% Answer: -% 3 ?- go3. -% P = 0.302995*B + 69.700522*MP - -go4:- mg(999, 3, Int, 0, 400), dump. - -% Answer: -% 400 = (-400 + (599 + 999*Int) * (1 + Int)) * (1 + Int) - -?- printf("\n>>> Sample goals: go1/0, go2/0, go3/0, go4/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/nrev b/CLPQR/clpqr/examples/monash/nrev deleted file mode 100644 index 378a24106..000000000 --- a/CLPQR/clpqr/examples/monash/nrev +++ /dev/null @@ -1,30 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -app([], L, L). -app([H | L1], L2, [H | L]) :- app(L1, L2, L). -rev([], []). -rev([H | L1], L) :- rev(L1, L2), app(L2, [H], L). - -% -% Naive reverse for 100 elements. -% - -go:- rev([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, -a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, -a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, -a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, -a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70, -a71, a72, a73, a74, a75, a76, a77, a78, a79, a80, a81, a82, a83, a84, -a85, a86, a87, a88, a89, a90, a91, a92, a93, a94, a95, a96, a97, a98, -a99, a100], X). - -?- printf("\n>>> Sample goal: go/0\n", []). - diff --git a/CLPQR/clpqr/examples/monash/option b/CLPQR/clpqr/examples/monash/option deleted file mode 100644 index 33c1df4dc..000000000 --- a/CLPQR/clpqr/examples/monash/option +++ /dev/null @@ -1,162 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Algebraic combinations of options: see [Lassez, McAloon & Yap]. -% - -% Note that buy and sell are the negation of each other - -% heaviside function -h(X,Y,Z) :- Y < X , Z = 0. -h(X,Y,Z) :- Y >= X, Z = 1. - -% ramp function -r(X,Y,Z) :- Y < X , Z = 0. -r(X,Y,Z) :- Y >= X, Z = Y - X. - -% option valuation -% Variables are as previously described -value(Type,Buy_or_Sell,S,C,P,I,X,B,Value) :- - check_param(S,C,P,I,X,B), - get_sign(Buy_or_Sell,Sign), - lookup_option(Type,S,C,P,I,X,B, - B1,B2,H1,H2,R1,R2), - h(B1,S,T1),h(B2,S,T2),r(B1,S,T3),r(B2,S,T4), - Value = Sign*(H1*T1 + H2*T2 + R1*T3 + R2*T4). - -% safety check -check_param(S,C,P,I,X,B) :- - S >= 0, C >= 0, P >= 0, - I >= 0, X >= 0, B >= 0 . - -% Buy or sell are just opposite -get_sign(buy,-1). -get_sign(sell,1). - -% lookup option vector -lookup_option(Type,S,C,P,I,X,B,B1,B2,H1,H2,R1,R2) :- - table(Type,S,C,P,I,X,B,B1,B2,H1,H2,R1,R2). - -% Table of values for B1,B2,H1,H2,R1,R2 -% generic format - lookup_table(Type,Pos_neg,S,C,P,I,X,B,B1,B2,H1,H2,R1,R2). -% where K to R21 are obtained from the table -% M is a multiplier which is -1 or 1 depending on whether one -% is buying or selling the option -table( stock, S, C, P, I, X, B, 0, 0, S*(1+I), 0, -1, 0). -table( call, S, C, P, I, X, B, 0, X, C*(1+I), 0, 0, -1). -table( put, S, C, P, I, X, B, 0, X, P*(1+I)-X, 0, 1, -1). -table( bond, S, C, P, I, X, B, 0, 0, B*(1+I), 0, 0, 0). - - -% A straightforward query is finding the -% value of selling a call option where -% the call price is 5, exercise price 50, -% interest rate 5% and current stock price 60. -% Note that this query assigns variables just -% to make the query look more readable -go1(Value) :- - Call=5,Exercise=50,Interest=0.05,Stock=60 , - value(call,sell,Stock,Call,_,Interest,Exercise,_,Value). - -% Answer: -% W = -4.75 - -% If we just the the question upside down and -% ask what should the stock price be in order that -% my wealth is more than 5. Then we have - -go2(Stock,W) :- - Call=5,Exercise=50,Interest=0.05 , - W > 5, - value(call,sell,Stock,Call,_,Interest,Exercise,_,W). - -% Answer 1: -% W = 5.25 -% 50 > S -% S >= 0 - -% Answer 2: -% W = 55.25 - S -% 50.25 > S -% S >= 50 - - -% straddle -% The general query is -% ?- Wealth=W1+W2,.... -% value(call,buy,S,C,_,I,X,_,W1), -% value(put,buy,S,_,P,I,X,_,W2). - -go3(Stock,W) :- - Call=5,Int=0.05,X=50,Put=7, - W >= 10, - value(put,buy,Stock,_,Put,Int,X,_,W1), - value(call,buy,Stock,Call,_,Int,X,_,W2), - W=W1+W2. - -% Answer 1: -% S = 37.4 - W -% W >= 10 -% S >= 0 - -% Answer 2: -% S = 62.6 + W -% W >= 10 -% S >= 0 - - -go4(S,W) :- - I=0.1,P1=10,X1=20, - value(put,sell,S,_,P1,I,X1,_,W1), - P2=18,X2=40, - value(put,buy,S,_,P2,I,X2,_,W2), - C3=15,X3=60, - value(call,buy,S,C3,_,I,X3,_,W3), - C4=10,X4=80, - value(call,sell,S,C4,_,I,X4,_,W4), - W=W1+W2+W3+W4. - -% Answer 1: -% W = 5.7 -% 20 > S -% S >= 0 - -% Answer 2: -% S = 25.7 - W -% 5.7 >= W -% 14.3 + W > 0 -% S >= 0 - -% Answer 3: -% W = -14.3 -% S >= 40 -% 60 > S - -% Answer 4: -% S = 74.3 + W -% 14.3 + W >= 0 -% 5.7 > W -% S >= 0 - -% Answer 5: -% W = 5.7 -% S >= 80 - -go5(S,W) :- - Put=5,Exercise=20,Interest=0.1, - S >= 0, - W > 100, - value(put,buy,S,_,Put,Interest,Exercise,_,W). - -% No solution. - -?- printf("\n>>> Sample goals (some with multiple answers):\n", []), - printf(" go1(W), go2(S, W), go3(S, W), go4(S, W), go5(S, W)\n", []). diff --git a/CLPQR/clpqr/examples/monash/pictures b/CLPQR/clpqr/examples/monash/pictures deleted file mode 100644 index 68130f4c0..000000000 --- a/CLPQR/clpqr/examples/monash/pictures +++ /dev/null @@ -1,164 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -/* - * This example is credited to Richard Helm & Kim Marriot - */ -% -% Package which allows rule-based descriptions of pictures to be translated into -% commands in the "pic" package. -% for example, try ?- tell(picout), go2, told. -% and then from the UNIX command line try -% pic picout | troff | ... -% - -inter( P1, P2 ,P3 ,P4 ,P5 ,P6 ) :- - - intersect(P1, P2, P3, P4, PP1 ) , - intersect(P1, P2, P5, P6, PP2 ) , - intersect(P5, P6, P3, P4, PP3 ) , - - line( [ PP1, PP2 ] ), - line( [ PP2, PP3 ] ), - line( [ PP3, PP1 ] ), - - darrow( [ P1, P2 ] , dashed ), - darrow( [ P3, P4 ] , dashed ), - darrow( [ P5, P6 ] , dashed ), - - text( c1, P1, rjust ), - text( c2, P3, rjust ), - text( c3, P5, rjust ). - -intersect(P1,P2,P3,P4,PP) :- - - gradient(P1,P2,M1), - gradient(P3,P4,M2), - - lineeq(P1,M1,C1), - lineeq(P3,M2,C2), - - lineeq( PP, M1, C1 ), - lineeq( PP, M2, C2 ). - -lineeq(p(X,Y),M, C ) :- Y = M * X + C. - -gradient(p(P1x,P1y),p(P2x,P2y),M ) :- - - M = ( P2y -P1y ) / ( P2x -P1x ) . - -%-------------------- -% the required pic interface -%-------------------- - -pstart(S) :- - printf(".PS %gi\n" , [ S ] ). - -pend :- - printf(".PE\n", [] ). - -box( box( p(Ox,Oy), p(Cx,Cy) ), DotDashInvis , Text ) :- - Mx = (Ox + Cx ) / 2 , - My = (Oy + Cy ) / 2 , - H = Cx - Cy , - W = Cy - Oy , - printf( "box at %g,%g width %g hieght %g \n" , [ Mx,My,W,H ] ) . - -line( [ p(Ox,Oy), p(Cx,Cy) ], Style ) :- - printf( "line from %g,%g to %g,%g %\n" , [ Ox,Oy,Cx,Cy,Style ] ) . - -darrow( [ p(Ox,Oy), p(Cx,Cy) ],Style ) :- - printf( "line from %g,%g to %g,%g %\n" , [ Ox,Oy,Cx,Cy,Style ] ) . - -arrow( [ p(Ox,Oy), p(Cx,Cy) ],Style ) :- - printf( "line from %g,%g to %g,%g %\n" , [ Ox,Oy,Cx,Cy,Style ] ) . - -line( [ p(Ox,Oy), p(Cx,Cy) ] ) :- - printf( "line from %g,%g to %g,%g \n" , [ Ox,Oy,Cx,Cy ] ) . - -text( Text , p(Ox,Oy), Just ) :- - printf( " %s %s %s at %g,%g %s \n" , [ '"', Text, '"', Ox, Oy, Just] ) . - -quadrilateral( Pt1, Pt2, Pt3, Pt4, MPt1, MPt2, MPt3, MPt4) :- - parallelogram(MPt1, MPt2, MPt3, MPt4) , - lineWithMidPoint(Pt1,Pt2,MPt1) , - lineWithMidPoint(Pt2,Pt3,MPt2) , - lineWithMidPoint(Pt3,Pt4,MPt3) , - lineWithMidPoint(Pt4,Pt1,MPt4) , - line([ MPt1, MPt2 ], dashed), - line([ MPt2, MPt3 ], dashed), - line([ MPt3, MPt4 ], dashed), - line([ MPt4, MPt1 ], dashed). - -lineWithMidPoint( p(P1x,P1y), p(P2x,P2y) , p(Mx,My) ) :- - P1x - Mx = Mx - P2x , - P1y - My = My - P2y , - line([ p(P1x,P1y) , p(P2x,P2y) ]). - -parallelogram(p(P1x,P1y), p(P2x,P2y), p(P3x,P3y), p(P4x,P4y)) :- - P1x - P2x = P4x - P3x, - P1y - P2y = P4y - P3y, - P1x - P4x = P2x - P3x, - P1y - P4y = P2y - P3y. - -go1:- - pstart(2), - inter( p(0,1), p(4,2) ,p(3.5,1) ,p(2,5) ,p(0.33,0.5) ,p(3,5.5 ) ), - pend. - -% Output: -% .PS 2i -% line from 3.2,1.8 to 0.688979,1.172245 -% line from 0.688979,1.172245 to 2.302393,4.193619 -% line from 2.302393,4.193619 to 3.2,1.8 -% line from 0,1 to 4,2 dashed -% line from 3.5,1 to 2,5 dashed -% line from 0.33,0.5 to 3,5.5 dashed -% " c1 " at 0,1 rjust -% " c2 " at 3.5,1 rjust -% " c3 " at 0.33,0.5 rjust -% .PE - -go2:- - pstart(3), - quadrilateral( p(0,0), p(8,10) ,p(10,10) ,p(10,1) ,_, _, _, _ ), - quadrilateral( p(0,20), p(0,15) ,p(10,15) ,p(10,20) ,_, _, _, _ ), - quadrilateral( p(5,30), p(10,23), p(15,30), p(10,25), _, _, _, _), - pend. - -% Output: -% .PS 3i -% line from 0,0 to 8,10 -% line from 8,10 to 10,10 -% line from 10,10 to 10,1 -% line from 10,1 to 0,0 -% line from 4,5 to 9,10 dashed -% line from 9,10 to 10,5.5 dashed -% line from 10,5.5 to 5,0.5 dashed -% line from 5,0.5 to 4,5 dashed -% line from 0,20 to 0,15 -% line from 0,15 to 10,15 -% line from 10,15 to 10,20 -% line from 10,20 to 0,20 -% line from 0,17.5 to 5,15 dashed -% line from 5,15 to 10,17.5 dashed -% line from 10,17.5 to 5,20 dashed -% line from 5,20 to 0,17.5 dashed -% line from 5,30 to 10,23 -% line from 10,23 to 15,30 -% line from 15,30 to 10,25 -% line from 10,25 to 5,30 -% line from 7.5,26.5 to 12.5,26.5 dashed -% line from 12.5,26.5 to 12.5,27.5 dashed -% line from 12.5,27.5 to 7.5,27.5 dashed -% line from 7.5,27.5 to 7.5,26.5 dashed -% .PE - -?- printf("\n>>> Sample goals: go1/0, go2/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/rkf45 b/CLPQR/clpqr/examples/monash/rkf45 deleted file mode 100644 index 8786e03e1..000000000 --- a/CLPQR/clpqr/examples/monash/rkf45 +++ /dev/null @@ -1,511 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% use clpr -z 1e-20 - -/* - * RKF45 implementation in CLP(R): See [Harland & Michaylov]. - * - * Assumes that the function is evaluated by a predicate of the form - * - * eval(T, Y, Yp), where T is the independent variable, - * Y the current vector of solutions, - * Yp the new vector derivative - * - * e.g. eval(T, [Y1,Y2], [T*T + Y1*Y1, T*T - Y2*Y2]). - * - * Note: machine epsilon is available as #zero (pre-defined constant). - * - * Separate "mode" from the rest - may help efficiency - */ - -/* - * solve(Y, T, Tout, Incr, Relerr, Abserr) - * Predicate called by the user - if he wants to specify a mode, he calls - * solve/7 direct (only needed for single_step mode). - * - * Y - initial position vector - * T - starting point for independent variable - * Tout - last point at which output is desired - * Incr - default output increment - * Relerr - relative error tolerance - * Abserr - absolute error tolerance - */ - -solve(Y, Tstart, Tend, Incr, Relerr, Abserr) :- - solve(Y, Tstart, Tend, Incr, Relerr, Abserr, normal). - -/* - * Error checks - */ -solve(_, _, _, 0, _, _, normal) :- - printf("Increment must be non-zero for normal mode\n",[]). -solve(_, _, _, _, Relerr, _, _) :- - Relerr < 0, - printf("Relative error must be non-negative\n",[]). -solve(_, _, _, _, _, Abserr, _) :- - Abserr < 0, - printf("Relative error must be non-negative\n",[]). -solve(_, T, T, _, _, _, _) :- - printf("No interval\n",[]). - -/* - * Everything seems ok, so proceed - */ -solve(Y, T, Tend, Incr, Relerr, Abserr, Mode) :- - set_yp(T, Y, Yp), % Nfe = Nfe + 1 - output(T, Y), - solve1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, 1, 0)). % Work out the rest - % Nfe = 1 - % Kop = 0 - -/* - * Commence main iteration - */ -solve1(user(_, T, Tend, Incr, _, _, _), work(_, _, Nfe, _, _)) :- - abs(T - Tend) < Incr / 4, - printf("\nIteration finished\n------------------\n",[]), - printf(" %d derivative evaluations\n",[Nfe]). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, reset(Mode, relerr)), _) :- - remin(Remin), - Relerr < 2* #zero + Remin, - printf("Warned you to reset it larger than %f\n", [Relerr]). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, reset(Mode, relerr)), - work(Yp, H, Nfe, Kop, Tout)) :- - remin(Remin), - Relerr >= 2* #zero + Remin, - solve1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout)). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, reset(Mode, abserr, Oerr)), _) :- - Abserr <= Oerr, - printf("Abserr must be increased - not set to %f\n", [Abserr]). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, reset(Mode, abserr, Oerr)), - work(Yp, H, Nfe, Kop, Tout)) :- - Abserr > Oerr, - solve1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout)). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), work(Yp, Nfe, Kop)) :- - % First time - need to set H - set_tout(T, Tend, Incr, Tout), % Next output point - set_hinit(T, Tout-T, Y, Yp, Relerr, Abserr, H), - set_kop(Kop, H, Tout-T, Newkop), - stop_or_iter(user(Y, T, Tend, Incr, Relerr, Abserr, normal), - work(Yp, H, Nfe, Newkop, Tout)). -solve1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - % H already set - continue on - work(Yp, H, Nfe, Kop, _)) :- - set_tout(T, Tend, Incr, Tout), - sign(Tout-T, S), - set_kop(Kop, S*H, Tout-T, Newkop), - stop_or_iter(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, S*H, Nfe, Newkop, Tout)). - -/* - * Perform certain error checks - */ -stop_or_iter(User, work(Yp, H, Nfe, Kop, Tout)) :- - Kop >= 100, - check_out(User, work(Yp, H, Nfe, 0, Tout), output_excess). -stop_or_iter(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), Work) :- - remin(Remin), - Relerr < 2* #zero + Remin, - check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), Work, relerr). -stop_or_iter(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout)) :- - Abs = abs(Tout-T), - Tabs = abs(T), - % Use Euler approximation - Abs <= 26* #zero*Tabs, - set_euler(Tout-T, Y, Yp, NewY), - % Nfe = Nfe + 1 - set_yp(Tout, NewY, NewYp), - print_or_it(user(NewY, Tout, Tend, Incr, Relerr, Abserr, - mode(Mode, output)), work(NewYp, H, Nfe+1, Kop, Tout)). -stop_or_iter(User, Work) :- - % Go on with main loop ....... - iter(User, Work). - -iter(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout)) :- - set_modeh(Tout-T, H, NewH, Out), - iter1(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, Out, nofail)), - work(Yp, NewH, Nfe, Kop, Tout)). - -iter1(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, Out, Hmode)), - work(Yp, H, Nfe, Kop, Tout)) :- - max_func_eval(Maxfunc), - Nfe >= Maxfunc, - check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout), max_func). -iter1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout)) :- - fehl(Y, T, Yp, H, Sum, Abserr, Relerr, Errest, Ind), - stop_or_iter1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe+5, Kop, Tout), Sum, Errest, Ind). - -stop_or_iter1(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, Out, Hmode)), - Work, _, _, vanished) :- - check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), Work, vanished). -stop_or_iter1(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout), Sum, Esttol, okay) :- - Esttol > 1, - set_smin(Esttol, S), - check_h(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, S*H, Nfe, Kop, Tout)). -stop_or_iter1(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, Out, Hmode)), - work(Yp, H, Nfe, Kop, Tout), Sum, Esttol, okay) :- - Esttol <= 1, - % Nfe = Nfe+1 - set_yp(T+H, Sum, NewYp), - set_hmax(Esttol, Hmode, T, H, NewH), - print_or_it(user(Sum, T+H, Tend, Incr, Relerr, Abserr, - mode(Mode, Out)), work(NewYp, NewH, Nfe+1, Kop, Tout)). - -print_or_it(user(Y, T, Tend, Incr, Relerr, Abserr, - mode(normal,proceed)), Work) :- - iter(user(Y, T, Tend, Incr, Relerr, Abserr, normal), Work). -print_or_it(user(Y, T, Tend, Incr, Relerr, Abserr, - mode(normal, output)), Work) :- - output(T, Y), - solve1(user(Y, T, Tend, Incr, Relerr, Abserr, normal), Work). -print_or_it(user(Y, T, Tend, Incr, Relerr, Abserr, - mode(single_step, _)), Work) :- - check_out(user(Y, T, Tend, Incr, Relerr, Abserr, single_step), Work). - -check_h(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, _, _)), - work(Yp, H, Nfe, Kop, Tout)) :- - Habs = abs(H), - Tabs = abs(T), - Habs <= 26* #zero*Tabs, - printf("Tabs = %e , Habs = %e , #zero = %e \n",[Tabs,Habs,#zero]), - check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), - work(Yp, H, Nfe, Kop, Tout), step_small). -check_h(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode, Out, _)), Work) :- - iter1(user(Y, T, Tend, Incr, Relerr, Abserr, mode(Mode,proceed,hfail)), - Work). - -/* - * check_out(user(Y, Tstart, Tend, Incr, Relerr, Abserr, Mode), - * work(Yp, H, Nfe, Kop, Tout), Flag) - * Checks the status variable Flag, and takes appropriate action. - * See if there is a user-defined procedure - */ -check_out(User, Work, Flag) :- - user_error(User, Work, Flag), - !. -% No user procedure, so use the default ones. -check_out(user(Y, T, Tend, Incr, Relerr, Abserr, single_step), - Work, single_step) :- - printf("(single_step) T: %10.6f Y: %10.6f\n",[T,Y]), - solve(Y, T, Tend, Incr, Relerr, Abserr, single_step),!. -check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), Work, relerr) :- - % Iflag = 3 - remin(Remin), - Rer = 3* #zero + Remin, - printf("Relative error too small - reset to %f\n", [Rer]), - solve1(user(Y, T, Tend, Incr, Rer, Abserr, reset(Mode, relerr)), Work). -check_out(User, work(Yp, H, Nfe, Kop, Tout), max_func) :- - % Iflag = 4 - max_func_eval(Max), - Nfe >= Max, - printf("Lots of function evaluations - %f needed so far\n",[Max]), - solve1(User, work(Yp, H, 0, Kop, Tout)). -check_out(user(Y, T, Tend, Incr, Relerr, Abserr, Mode), Work, vanished) :- - % Iflag = 5 - abmin(Absmin), - printf("Abserr reset to %f\n", [Absmin]), - solve1(user(Y, T, Tend, Incr, Relerr, 10*Abserr + Absmin, - reset(Mode, abserr, Abserr)), Work). -check_out(user(Y, T, Tend, Incr, Relerr, Abserr, normal), Work, step_small) :- - % Iflag = 6 - printf("Relerr too small; reset to %f\n", [10*Relerr]), - solve1(user(Y, T, Tend, Incr, 10*Relerr, Abserr, normal), Work). -check_out(User, work(Yp, H, Nfe, Kop, Tout), output_excess) :- - % Iflag = 7 - printf("Excessive output; this will be inefficient",[]), - solve1(User, work(Yp, H, Nfe, 0, Tout)). -check_out(_, _, stuffed) :- - % Iflag = 8 - printf("Improper call - wrong number of arguments?\n"). -check_out(_, _, missing) :- - printf("User-supplied predicate eval is missing or wrong\n"), - printf("Format is eval(T, Y, Yp),\n",[]), - printf("where T is the independent variable, ",[]), - printf("Y the vector, and Yp its derivative.",[]), - printf("Y and Yp are CLP lists - [Y1, Y2, Y3], [Yp1, Yp2, Yp3] etc.",[]). -check_out(_, _, Other) :- - printf("Damned if I know what''s wrong!\n",[]). - -/* - * output(T, Y). - * output(user(Y, T, Tend, Incr, Relerr, Abserr), work(Yp, H, Nfe, Kop, Tout)) - * Output predicate. If there is a user_output predicate (matching the above - * format), then it is used. Otherwise, T and Y are written to standard output. - */ -output(T, Y) :- - user_output(T, Y), - !. -output(T, Y) :- - printf("T: %10.6f Y: ",[T]), - write_list(Y). - -write_list([L|List]) :- - printf(" %10.6f ",[L]), - write_list(List). -write_list([]) :- - nl. - -/* - * Set routines - setting values of variables given certain conditions etc. - */ - -set_yp(T, Y, Yp) :- - eval(T, Y, Yp). -set_yp(T, [Y], [Yp]) :- - % For one var case with no list functor - eval(T, Y, Yp). - -set_hinit(T, Dt, Y, Yp, Relerr, Abserr, H) :- - H1 = abs(Dt), - set_maxtol(H1, Y, Yp, Relerr, Abserr, Maxtol), - set_h1(H1, T, Dt, Maxtol, H). - -set_maxtol(H, [Y|Yrest], [Yp|Yprest], Relerr, Abserr, Maxtol) :- - Yabs = abs(Y), - Tol1 = Relerr*Yabs + Abserr, - Tol1 > 0, - Ypabs = abs(Yp), - set_maxh(Ypabs, H, Tol1, H1), - set_maxtol(H1, Yrest, Yprest, Relerr, Abserr, Tol2), - Maxtol = max(Tol1, Tol2). -set_maxtol(H, [Y|Yrest], [Yp|Yprest], Relerr, Abserr, Maxtol) :- - Yabs = abs(Y), - Relerr*Yabs + Abserr <= 0, - set_maxtol(H, Yrest, Yprest, Relerr, Abserr, Maxtol). -set_maxtol(_, [], [], _, _, 0). - -set_maxh(0, H, _, H). -set_maxh(Ypabs, H, Tol, NewH) :- - Ypabs > 0, - NewH = min(H, pow(Tol/Ypabs, 1/5)). % From abs(Yp)*h**5 <= Tol - -set_h1(H, T, Dt, Tol, 26* #zero*Max) :- - Tol <= 0, - Tabs = abs(T), - Dtabs = abs(Dt), - Max = max(Tabs, Dtabs). -set_h1(H, T, Dt, Tol, NewH) :- - Tol > 0, - Tabs = abs(T), - Dtabs = abs(Dt), - Max = max(Tabs, Dtabs), - NewH = max(H, 26* #zero*Max). - -set_modeh(Dt, H, H, proceed) :- - Dtabs = abs(Dt), - Habs = abs(H), - Dtabs >= 2*Habs. -set_modeh(Dt, H, Dt/2, proceed) :- - Habs = abs(H), - Dtabs = abs(Dt), - Dtabs < 2*Habs, - Dtabs > Habs. -set_modeh(Dt, H, Dt, output) :- - Habs = abs(H), - Dtabs = abs(Dt), - Dtabs <= Habs. - -set_kop(Kop, H, Dt, Kop+1) :- - Habs = abs(H), - Dabs = abs(Dt), - Habs >= 2*Dabs. -set_kop(Kop, H, Dt, Kop) :- - Habs = abs(H), - Dabs = abs(Dt), - Habs < 2*Dabs. - -set_smin(Esttol, 0.9/(pow(Esttol, 1/5)) ) :- - Esttol < 59049. -set_smin(Esttol, 0.1) :- - Esttol >= 59049. - -set_hmax(Esttol, Hmode, T, H, Sign*H1) :- - set_smax(Esttol, Hmode, S), - Habs = abs(H), - Tabs = abs(T), - H1 = max(S*Habs, 26* #zero*Tabs), - sign(H, Sign). - -set_smax(Esttol, nofail, 5) :- - Esttol <= 0.0001889568. -set_smax(Esttol, nofail, 0.9/(pow(Esttol, 1/5)) ) :- - Esttol > 0.0001889568. -set_smax(Esttol, hfail, 1) :- - Esttol <= 0.0001889568. -set_smax(Esttol, hfail, S) :- - Esttol > 0.0001889568, - S = min(0.9/(pow(Esttol, 1/5)), 1). - -set_euler(Dt, [Y|Yrest], [Yp|Yprest], [NewY|NewYrest]) :- - NewY = Y + Dt*Yp, - set_euler(Dt, Yrest, Yprest, NewYrest). -set_euler(_, [], [], []). - -/* - * set_tout(T, Tend, Incr, Tout) - * Tout is the next output point, T the current value, Tend the final point - * and Incr the set increment. - * - * If there is a user-supplied predicate user_tout, then it is used. - * Otherwise, we add Incr to T and proceed. - * Note that Incr may be negative. - */ -set_tout(T, Tend, Incr, Tout) :- - user_tout(T, Tend, Incr, Tout), - !. -set_tout(T, Tend, Incr, Tend) :- - Abs = abs(Tend - (T + Incr)), - Abs < Incr. -set_tout(T, Tend, Incr, T + Incr) :- - Abs = abs(Tend - (T + Incr)), - Abs >= Incr. - -/* - * fehl(Y, T, Yp, H, Sum, Abserr, Relerr, Errest, Errind) - * Predicate to perform the evaluation of Fehlberg formulae - * - * Sum is the new estimate for Y - * Abserr is the absolute error. - * Relerr is the relative error. - * Errest is the Fehlberg estimate of the error. - * Errind indicates whether Abs is too small or not. - * If so, Errind is set to "vanished". Otherwise, it is "okay". - */ -fehl(Y, T, Yp, H, S, Abs, Rel, Err, Ind) :- - Ch1 = H/4, - Ch2 = H*3/32, - Ch3 = H/2197, - Ch4 = H/4104, - Ch5 = H/20520, - Ch6 = H/7618050, - fehl1(Y, T, Yp, H, ch(Ch1, Ch2, Ch3, Ch4, Ch5, Ch6), - S, Abs, Rel, Err, Ind). - -fehl1(Y, T, Yp, H, ch(Ch1, Ch2, Ch3, Ch4, Ch5, Ch6), S, Abs, Rel, Err, Ind) :- - % calculate each of the Fi ..... - set_f1(Y, Yp, Ch1, P1), set_yp(T+Ch1, P1, F1), - set_f2(Y, Yp, Ch2, F1, P2), set_yp(T+ 3*H/8, P2, F2), - set_f3(Y, Yp, Ch3, F1, F2, P3), set_yp(T + 12*H/13, P3, F3), - set_f4(Y, Yp, Ch4, F1, F2, F3, P4), set_yp(T + H, P4, F4), - set_f5(Y, Yp, Ch5, F1, F2, F3, F4, P5), set_yp(T + H/2, P5, F5), - % .. then the Y estimate .... - set_sum(Y, Yp, Ch6, F2, F3, F4, F5, S), - % .. and finally the error - set_err(Y, Yp, Abs, Rel, S, f(F2, F3, F4, F5), H, 0, Err, Ind). - -set_f1([Y|Yr], [Yp|Ypr], Ch, [P|Pr]) :- - P = Y + Ch*Yp, - set_f1(Yr, Ypr, Ch, Pr). -set_f1([], [], _, []). - -set_f2([Y|Yr], [Yp|Ypr], Ch, [F1|F1r], [P|Pr]) :- - P = Y + Ch*(Yp + 3*F1), - set_f2(Yr, Ypr, Ch, F1r, Pr). -set_f2([], [], _, [], []). - -set_f3([Y|Yr], [Yp|Ypr], Ch, [F1|F1r], [F2|F2r], [P|Pr]) :- - P = Y + Ch*(1932*Yp + (7296*F2 - 7200*F1)), - set_f3(Yr, Ypr, Ch, F1r, F2r, Pr). -set_f3([], [], _, [], [], []). - -set_f4([Y|Yr], [Yp|Ypr], Ch, [F1|F1r], [F2|F2r], [F3|F3r], [P|Pr]) :- - P = Y + Ch*((8341*Yp - 845*F3) + (29440*F2 - 32832*F1)), - set_f4(Yr, Ypr, Ch, F1r, F2r, F3r, Pr). -set_f4([], [], _, [], [], [], []). - -set_f5([Y|Yr], [Yp|Ypr], Ch, [F1|F1r], [F2|F2r], [F3|F3r], [F4|F4r], [P|Pr]) :- - P = Y + Ch*((0-6080*Yp + (9295*F3 - 5643*F4)) + (41040*F1-28352*F2)), - set_f5(Yr, Ypr, Ch, F1r, F2r, F3r, F4r, Pr). -set_f5([], [], _, [], [], [], [], []). - -set_sum([Y|Yr], [Yp|Ypr], Ch, [F2|F2r], [F3|F3r], [F4|F4r], [F5|F5r], [S|Sr]) :- - S = Y + Ch*((902880*Yp + (3855735*F3 - 1371249*F4)) + (3953664*F2 + - 277020*F5)), - set_sum(Yr, Ypr, Ch, F2r, F3r, F4r, F5r, Sr). -set_sum([], [], _, [], [], [], [], []). - -set_err([Y|Yr], Yp, Abs, Rel, [S|Sr], f(F2, F3, F4, F5), H, Oerr, Err, Ind) :- - Yabs = abs(Y), - Sabs = abs(S), - Et = Yabs + Sabs + Abs, - check_err(Et, [Y|Yr], Yp, [S|Sr], f(F2, F3, F4, F5), - Abs, Rel, H, Oerr, Err, Ind). -set_err([], [], _, Rel, [], _, H, Err, Habs*Err*(2/Rel)/752400, okay) :- - Habs = abs(H). - -check_err(Et, Y, Yp, S, _, _, _, _, _, _, vanished) :- - Et <= 0. -check_err(Et, [Y|Yr], [Yp|Ypr], [S|Sr], f([F2|R2], [F3|R3], [F4|R4], [F5|R5]), - Abs, Rel, H, Oerr, Err, Ind) :- - Et > 0, - Ee = abs( (0-2090*Yp + (21970*F3 - 15048*F4)) + (22528*F2 - 27360*F5)), - Nerr = max(Oerr, Ee/Et), - set_err(Yr, Ypr, Abs, Rel, Sr, f(R2, R3, R4, R5), H, Nerr, Err, Ind). - -% Low level stuff - primitives etc. - -sign(V, 1) :- - V >= 0. -sign(V, 0-1) :- - V < 0. - -% Magic numbers -remin(0.000000000001). % 1.0e-012 - from FM&M. -abmin(0.000000001). % 1.0e-009 - from FM&M. -max_func_eval(3000). % Also from FF&M. - -eval(T, [Y1, Y2, Y3, Y4], [Y3, Y4, 0-Y1/R, 0-Y2/R]) :- - R1 = Y1*Y1 + Y2*Y2, - R = R1*pow(R1, 0.5)/((#p/4)*(#p/4)). - -user_output(T, [Y1, Y2, Y3, Y4]) :- - printf("Point %10.5f : %10.5f %10.5f\n",[T,Y1,Y2]). - -user_error(user(Y, T, Tend, Incr, Rer, Abs), - work(Yp, H, Nfe, Kop, Tout), max_func) :- - printf("Too hard for me - try something more accurate\n",[]). - -user_error(user(Y, T, Tend, Incr, Rer, Abs), - work(Yp, H, Nfe, Kop, Tout), output_excess) :- - printf("Outputs too often - try another method\n",[]). - -user_error(user(Y, T, Tend, Incr, Rer, Abs), - work(Yp, H, Nfe, Kop, Tout), step_small) :- - printf("Can''t achieve required accuracy\n",[]). - -go:- Ecc = 0.25, solve([1-Ecc, 0, 0, (#p/4)*pow((1+Ecc)/(1-Ecc), 0.5)], - 0, 3, 0.5, 0.000000001, 0). - -% Output: -% -% Point 0.00000 : 0.75000 0.00000 -% Point 0.50000 : 0.61977 0.47779 -% Point 1.00000 : 0.29442 0.81218 -% Point 1.50000 : -0.10518 0.95804 -% Point 2.00000 : -0.49030 0.93987 -% Point 2.50000 : -0.81394 0.79959 -% Point 3.00000 : -1.05403 0.57571 -% -% Iteration finished -% ------------------ -% 439 derivative evaluations - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/rlc b/CLPQR/clpqr/examples/monash/rlc deleted file mode 100644 index 32c7e48e2..000000000 --- a/CLPQR/clpqr/examples/monash/rlc +++ /dev/null @@ -1,420 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Package for sinusoidal steady state analysis of RLC circuits. -% The two goals ?- go1 and ?- go2 analyse two -% circuits of moderate complexity. -% - - -circuit_solve(W, L, G, Selection) :- - get_node_vars(L, NV), - solve(W, L, NV, Handles, G), - format_print(Handles, Selection). - -get_node_vars([[Comp, Num, X, Ns]|Ls], NV) :- - get_node_vars(Ls, NV1), - insert_list(Ns, NV1, NV). -get_node_vars([], []). - -insert_list([N|Ns], NV1, NV3) :- - insert_list(Ns, NV1, NV2), - insert(N, NV2, NV3). -insert_list([], NV, NV). - -insert(N, [[N, V, I]|NV1], [[N, V, I]|NV1]) :- !. -insert(N, [[N1, V, I]|NV1], [[N1, V, I]|NV2]) :- - insert(N, NV1, NV2). -insert(N, [], [[N, V, c(0,0)]]). - -eps(0.001). - -solve(W, [X|Xs], NV, [H|Hs], G) :- - addcomp(W, X, NV, NV1,H), - solve(W, Xs, NV1, Hs, G). -solve(W, [], NV, [], G) :- - !, - zero_currents(NV), - ground_nodes(NV, G). - -zero_currents([[N, V, c(X,Y)]|Ls]) :- - zero(X), - zero(Y), - zero_currents(Ls). -zero_currents([]). - -zero(0). -zero(X) :- - ground(X), - %printf("Is it ground: % ?\n", [X]), - eps(EPS), - X > -EPS, - X < EPS. - -/* There is some redundancy setting all node current sums to zero - We only - need to some of them to zero. Setting all of them to zero can cause some - problems because of numerical instability. */ - -ground_nodes(Vs,[N|Ns]) :- - ground_node(Vs, N), - ground_nodes(Vs, Ns). -ground_nodes(Vs, []). -ground_node([[N, c(0,0), I]|Vs], N) :- !. -ground_node([[N1, V, I]|Vs], N) :- ground_node(Vs, N). -ground_node([], N) :- printf("Error could be: node %doesn't exist\n", [N]). - - -% ***** CLAUSES TO DEFINE COMPONENT CHARACTERISTICS ***** - -addcomp(W, [Comp2, Num, X, [N1, N2]], NV, NV2, [Comp2, Num, X, [N1, V1, I1], [N2, V2, I2]]):- - c_neg(I1, I2), - iv_reln(Comp2, I1, V, X, W), - c_add(V, V2, V1), - subst([N1, V1, Iold1], [N1, V1, Inew1], NV, NV1), - subst([N2, V2, Iold2], [N2, V2, Inew2], NV1, NV2), - c_add(I1,Iold1,Inew1), - c_add(I2,Iold2,Inew2). - -% Specific current/voltage relations for the two terminal components -iv_reln(resistor, I, V, R, W) :- - c_mult(I,c(R,0),V). -iv_reln(voltage_source, I, V, V, W). -iv_reln(isource, I, V, I, W). -iv_reln(capacitor, I, V, C, W) :- - c_mult( c(0,W * C),V,I). -iv_reln(inductor, I, V, L, W) :- - c_mult(c(0,W * L),I,V). -iv_reln(connection, I, c(0,0), L, W). -iv_reln(open, c(0,0), V, L, W). -iv_reln(diode, I, V, D, W) :- diode(D, I, V). - -diode(in914, c(I,0), c(V, 0)) :- - V < -100, - DV = V + 100, - I = 10*DV. -diode(in914, c(I,0), c(V, 0)) :- - V >= -100, - V < 0.6, - I = 0.001*V. -diode(in914, c(I,0), c(V, 0)) :- - V >= 0.6, - DV = V - 0.6, - I = 100*DV. - -addcomp(W, [transistor, Num, X, [N1, N2, N3]], NV, NV3, [transistor, Num, X, [N1, V1, I1], [N2, V2, I2], [N3, V3, I3]]):- - transistor(X, R, Gain), - c_add(I1, I3, IT), - c_neg(I2, IT), - c_add(Vin, V2, V1), - c_mult(I1, c(R, 0), Vin), - c_mult(I1, c(Gain, 0), I3), - subst([N1, V1, Iold1], [N1, V1, Inew1], NV, NV1), - subst([N2, V2, Iold2], [N2, V2, Inew2], NV1, NV2), - subst([N3, V3, Iold3], [N3, V3, Inew3], NV2, NV3), - subst([N4, V4, Iold4], [N4, V4, Inew4], NV3, NV4), - c_add(I1,Iold1,Inew1), - c_add(I2,Iold2,Inew2), - c_add(I3,Iold3,Inew3), - c_add(I4,Iold4,Inew4). - -transistor(bc108, 1000, 100). - -addcomp(W, [transformer, Num, X, [N1, N2, N3, N4]], NV, NV4, [transformer, Num, X, [N1, V1, I1], [N2, V2, I2], [N3, V3, I3], [N4, V4, I4]]):- - c_neg(I1, I2), - c_neg(I3, I4), - c_add(Vin, V2, V1), - c_add(Vout, V4, V3), - c_mult(Vout, c(X, 0), Vin), - c_mult(I1, c(X, 0), I4), - subst([N1, V1, Iold1], [N1, V1, Inew1], NV, NV1), - subst([N2, V2, Iold2], [N2, V2, Inew2], NV1, NV2), - subst([N3, V3, Iold3], [N3, V3, Inew3], NV2, NV3), - subst([N4, V4, Iold4], [N4, V4, Inew4], NV3, NV4), - c_add(I1,Iold1,Inew1), - c_add(I2,Iold2,Inew2), - c_add(I3,Iold3,Inew3), - c_add(I4,Iold4,Inew4). - - -subst(X, Y, [X|L1], [Y|L1]) :- !. -subst(X, Y, [Z|L1], [Z|L2]) :- - subst(X,Y,L1,L2). -subst(X, Y, [], L2) :- - printf("Node list incomplete\n", []). - - -% ***** COMPLEX NUMBER ARITHMETIC ***** - -c_mult(c(Re1,Im1),c(Re2,Im2),c(Re3,Im3)) :- - Re3 = Re1*Re2 - Im1*Im2, - Im3 = Re1*Im2 + Re2*Im1. - -c_add(c(Re1,Im1),c(Re2,Im2),c(Re3,Im3)) :- - Re3 = Re1 + Re2, - Im3 = Im1 + Im2. - -c_neg(c(Re,Im),c(Re1,Im1)) :- - Re1 = -Re, Im1 = -Im . - -c_eq(c(Re1,Im1),c(Re2,Im2)) :- - Re1 = Re2, Im1 = Im2 . - -c_real(c(Re,Im),Re). - -c_imag(c(Re,Im),Im). - - -% ****** PRINTOUT ROUTINES ****** - -format_print(H, []) :- - !, - all_print(H). - % If no selection is given then - % print out all nodes. -format_print(H, Selection) :- - selective_print(H, Selection). - % Otherwise print the selection. - -selective_print(Ls, [N|Ns]) :- - print_nodes(Ls, N, 0), - print_comps(Ls, N), - selective_print(Ls, Ns). -selective_print(Ls, []). - -print_nodes([[Comp, Num, X|Nodes]|L], N1, Heading_flag_1) :- - member(N1, Nodes), - Heading_flag_2 = Heading_flag_1 + 1, - heading(N1, Heading_flag_2), - all_print([[Comp, Num, X|Nodes]]), - print_nodes(L, N1, Heading_flag_2). -print_nodes([[Comp, Num, X|Nodes]|L], N1, Heading_flag) :- - print_nodes(L, N1, Heading_flag). -print_nodes([], N1, Heading_flag). - -print_comps([[Comp, Num, X|Nodes]|L], Num) :- - all_print([[Comp, Num, X|Nodes]]), - print_comps(L, Num). -print_comps([[Comp, Num, X|Nodes]|L], Num1) :- - print_comps(L, Num1). -print_comps([], Num). - -heading(N, 1) :- - !, - printf("\nCOMPONENT CONNECTIONS TO NODE %\n", [N]). -heading(N, X). - -member(N1, [[N1, V, I]|Ls]). -member(N1, [[N2, V, I]|Ls]) :- - member(N1, Ls). - -write_units(resistor, X) :- - printf("% Ohms",[X]). -write_units(capacitor, X) :- - printf("% Farads",[X]). -write_units(inductor, X) :- - printf("% Henrys", [X]). -write_units(current_source, X) :- - printf("% Ampere", [X]). -write_units(voltage_source, X) :- - printf("% Volts", [X]). -write_units(diode, X) :- - printf("type %", [X]). -write_units(transistor, X) :- - printf("type % (base, emitter, collector)", [X]). -write_units(transformer, X) :- - printf("ratio of %", [X]). - -all_print([[Comp, Num, X|Nodes]|L]) :- - printf("% %: ", [Comp, Num]), - write_units(Comp, X), - printf("\n", []), - pr_nodes(Nodes), - all_print(L). -all_print([]). - -pr_nodes([[N1, V1, I1]|X]) :- - printf(" Node %\n", [N1]), - printf(" Voltage %\n", [V1]), - printf(" Current %\n", [I1]), - pr_nodes(X). -pr_nodes([]) :- - printf("\n", []). - - -go1:- -W = 10, -Vs = 10, -R = 10, -L = 0.9, -C = 0.007, -circuit_solve(W, - [ - [voltage_source,v1,c(Vs,0),[n1,n7]], - [resistor,r1,R,[n1,n2]], - [resistor,r2,R,[n1,n3]], - [resistor,r3,R,[n1,n4]], - [resistor,r4,R,[n1,n5]], - [resistor,r5,R,[n1,n6]], - [inductor,l1,L,[n2,n7]], - [inductor,l2,L,[n3,n7]], - [inductor,l3,L,[n4,n7]], - [inductor,l4,L,[n5,n7]], - [inductor,l5,L,[n6,n7]], - [capacitor,c1,C,[n2,n3]], - [capacitor,c2,C,[n2,n4]], - [capacitor,c3,C,[n2,n5]], - [capacitor,c4,C,[n2,n6]], - [capacitor,c5,C,[n3,n4]], - [capacitor,c6,C,[n3,n5]], - [capacitor,c7,C,[n3,n6]], - [capacitor,c8,C,[n4,n5]], - [capacitor,c9,C,[n4,n6]], - [capacitor,c10,C,[n5,n6]] - ], - [n7], - [r1, r3, l1, l3, c8, l5] - ). - -% Output: -% resistor r1: 10 Ohms -% Node n1 -% Voltage c(10, 0) -% Current c(0.552486, -0.497238) -% Node n2 -% Voltage c(4.475138, 4.972376) -% Current c(-0.552486, 0.497238) -% -% resistor r3: 10 Ohms -% Node n1 -% Voltage c(10, 0) -% Current c(0.552486, -0.497238) -% Node n4 -% Voltage c(4.475138, 4.972376) -% Current c(-0.552486, 0.497238) -% -% inductor l1: 0.9 Henrys -% Node n2 -% Voltage c(4.475138, 4.972376) -% Current c(0.552486, -0.497238) -% Node n7 -% Voltage c(0, 0) -% Current c(-0.552486, 0.497238) -% -% inductor l3: 0.9 Henrys -% Node n4 -% Voltage c(4.475138, 4.972376) -% Current c(0.552486, -0.497238) -% Node n7 -% Voltage c(0, 0) -% Current c(-0.552486, 0.497238) -% -% capacitor c8: 0.007 Farads -% Node n4 -% Voltage c(4.475138, 4.972376) -% Current c(0, 0) -% Node n5 -% Voltage c(4.475138, 4.972376) -% Current c(0, 0) -% -% inductor l5: 0.9 Henrys -% Node n6 -% Voltage c(4.475138, 4.972376) -% Current c(0.552486, -0.497238) -% Node n7 -% Voltage c(0, 0) -% Current c(-0.552486, 0.497238) -% - - -go2:- -Vs = 10, -Tr1 = 5, -Tr2 = 0.2, -R1 = 1000, -R2 = 200, -R3 = 50, -R4 = 30, -circuit_solve(W, - [ - [voltage_source, v1, c(Vs,0),[in, ground1]], - [resistor, r1, R2, [in, n1]], - [transformer, t1, Tr1,[n1, ground1, n2, ground2]], - [resistor, r2, R1, [n2, base]], - [transistor, q1, bc108, [base, n3, n4]], - [resistor, r3, R2, [n3, ground2]], - [resistor, r3, R2, [n4, ground2]], - [transformer, t2, Tr2,[n4, ground2, out, ground3]], - [resistor, r5, R4, [out, ground3]] - ], - [ground1, ground2, ground3], - [n4, out]). - -% Output: -% COMPONENT CONNECTIONS TO NODE n4 -% transistor q1: type bc108 (base, emitter, collector) -% Node base -% Voltage c(1.909222, 0) -% Current c(9.005764e-005, 0) -% Node n3 -% Voltage c(1.819164, 0) -% Current c(-0.009096, 0) -% Node n4 -% Voltage c(-0.010742, 0) -% Current c(0.009006, 0) -% -% resistor r3: 200 Ohms -% Node n4 -% Voltage c(-0.010742, 0) -% Current c(-5.371231e-005, 0) -% Node ground2 -% Voltage c(0, 0) -% Current c(5.371231e-005, 0) -% -% transformer t2: ratio of 0.2 -% Node n4 -% Voltage c(-0.010742, 0) -% Current c(-0.008952, 0) -% Node ground2 -% Voltage c(0, 0) -% Current c(0.008952, 0) -% Node out -% Voltage c(-0.053712, 0) -% Current c(0.00179, 0) -% Node ground3 -% Voltage c(0, 0) -% Current c(-0.00179, 0) -% -% -% COMPONENT CONNECTIONS TO NODE out -% transformer t2: ratio of 0.2 -% Node n4 -% Voltage c(-0.010742, 0) -% Current c(-0.008952, 0) -% Node ground2 -% Voltage c(0, 0) -% Current c(0.008952, 0) -% Node out -% Voltage c(-0.053712, 0) -% Current c(0.00179, 0) -% Node ground3 -% Voltage c(0, 0) -% Current c(-0.00179, 0) -% -% resistor r5: 30 Ohms -% Node out -% Voltage c(-0.053712, 0) -% Current c(-0.00179, 0) -% Node ground3 -% Voltage c(0, 0) -% Current c(0.00179, 0) -% - -?- printf("\n>>> Sample goals: go1/0, go2/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/smm b/CLPQR/clpqr/examples/monash/smm deleted file mode 100644 index 3237793c6..000000000 --- a/CLPQR/clpqr/examples/monash/smm +++ /dev/null @@ -1,101 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Crypto-arithmetic puzzle: -% Need to assign integers from 0 to 9 to the letters S, E, N, D, M, O, R, Y -% without duplicates such that the equation -% -% S E N D -% + M O R E -% --------- -% M O N E Y -% -% is satisfied. -% - -p(S, E, N, D, M, O, R, Y) :- - S > 0, E >= 0, N >= 0, D >= 0, M > 0, O >= 0, R >= 0, Y >= 0, - S <= 9, E <= 9, N <= 9, D <= 9, M <= 9, O <= 9, R <= 9, Y <= 9, - D + E = Y + 10*C1, - C1 + N + R = E + 10*C2, - C2 + E + O = N + 10*C3, - C3 + S + M = O + 10*M, - carry(C1, C2, C3), - dig(S), dig(E), dig(N), dig(D), dig(M), dig(O), dig(R), dig(Y), - printf("S = %d, E = %d, N = %d, D = %d, M = %d, O = %d, R = %d, Y = %d \n",[S, E, N, D, M, O, R, Y]), - difflist([S, E, N, D, M, O, R, Y]). - -carry(1, 1, 1). -carry(1, 1, 0). -carry(1, 0, 1). -carry(1, 0, 0). -carry(0, 1, 1). -carry(0, 1, 0). -carry(0, 0, 1). -carry(0, 0, 0). - -dig(9). -dig(8). -dig(7). -dig(6). -dig(5). -dig(4). -dig(3). -dig(2). -dig(1). -dig(0). - -difflist([X | T]) :- notmem(X, T), difflist(T). -difflist([]). - -notmem(X, [Y | Z]) :- X < Y, notmem(X, Z). -notmem(X, [Y | Z]) :- X > Y, notmem(X, Z). -notmem(X, []). - -/**************************************************************/ -/*** S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 ***/ -/**************************************************************/ - -go:- - p(S, E, N, D, M, O, R, Y), - printf("\nAns:\n",[]), - printf("S = %d, E = %d, N = %d, D = %d, M = %d, O = %d, R = %d, Y = %d \n",[S, E, N, D, M, O, R, Y]). - -% Output: -% S = 9, E = 8, N = 9, D = 9, M = 1, O = 0, R = 8, Y = 7 -% S = 9, E = 8, N = 9, D = 8, M = 1, O = 0, R = 8, Y = 6 -% S = 9, E = 8, N = 9, D = 7, M = 1, O = 0, R = 8, Y = 5 -% S = 9, E = 8, N = 9, D = 6, M = 1, O = 0, R = 8, Y = 4 -% S = 9, E = 8, N = 9, D = 5, M = 1, O = 0, R = 8, Y = 3 -% S = 9, E = 8, N = 9, D = 4, M = 1, O = 0, R = 8, Y = 2 -% S = 9, E = 8, N = 9, D = 3, M = 1, O = 0, R = 8, Y = 1 -% S = 9, E = 8, N = 9, D = 2, M = 1, O = 0, R = 8, Y = 0 -% S = 9, E = 7, N = 8, D = 9, M = 1, O = 0, R = 8, Y = 6 -% S = 9, E = 7, N = 8, D = 8, M = 1, O = 0, R = 8, Y = 5 -% S = 9, E = 7, N = 8, D = 7, M = 1, O = 0, R = 8, Y = 4 -% S = 9, E = 7, N = 8, D = 6, M = 1, O = 0, R = 8, Y = 3 -% S = 9, E = 7, N = 8, D = 5, M = 1, O = 0, R = 8, Y = 2 -% S = 9, E = 7, N = 8, D = 4, M = 1, O = 0, R = 8, Y = 1 -% S = 9, E = 7, N = 8, D = 3, M = 1, O = 0, R = 8, Y = 0 -% S = 9, E = 6, N = 7, D = 9, M = 1, O = 0, R = 8, Y = 5 -% S = 9, E = 6, N = 7, D = 8, M = 1, O = 0, R = 8, Y = 4 -% S = 9, E = 6, N = 7, D = 7, M = 1, O = 0, R = 8, Y = 3 -% S = 9, E = 6, N = 7, D = 6, M = 1, O = 0, R = 8, Y = 2 -% S = 9, E = 6, N = 7, D = 5, M = 1, O = 0, R = 8, Y = 1 -% S = 9, E = 6, N = 7, D = 4, M = 1, O = 0, R = 8, Y = 0 -% S = 9, E = 5, N = 6, D = 9, M = 1, O = 0, R = 8, Y = 4 -% S = 9, E = 5, N = 6, D = 8, M = 1, O = 0, R = 8, Y = 3 -% S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 -% -% Ans: -% S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2 - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/toolpath b/CLPQR/clpqr/examples/monash/toolpath deleted file mode 100644 index c26460371..000000000 --- a/CLPQR/clpqr/examples/monash/toolpath +++ /dev/null @@ -1,116 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% Program to translate declarative machine tool path descriptions into -% code for a programmable controller. -% - -move_p(p(_,X,Y)):- - printf("G00 X%-.3f Y%-.3f\n",[X,Y]). -draw_p(p(_,X,Y)):- - printf("G01 X%-.3f Y%-.3f\n",[X,Y]). - -lookup(X,[X|T]). -lookup(X,[H|T]):- - lookup(X,T). - -path([p(N)|T],DB):- - lookup(p(N,X,Y),DB), - move_p(p(N,X,Y)), - rest_path(T,DB). - -rest_path([p(N)|T],DB):- - lookup(p(N,X,Y),DB), - draw_p(p(N,X,Y)), - rest_path(T,DB). -rest_path([],_). - -make_vars([H|T],V,[NV|EV]):- - get_vars(H,NV), - make_vars(T,V,EV). -make_vars([],V,V). - -get_vars(p(N,xy(X,Y)),p(N,X,Y)). -get_vars(p(N,l(A),l(B)),p(N,X,Y)). -get_vars(l(N,mc(M,C)),l(N,M,C)). -get_vars(l(N,p(A),p(B)),l(N,M,C)). - -make_constraints([H|T],V):- - get_constraint(H,V), - make_constraints(T,V). -make_constraints([],_). - -get_constraint(p(N,l(A),l(B)),V):- - Y = M1 * X + C1, - Y = M2 * X + C2, - lookup(p(N,X,Y),V), - lookup(l(A,M1,C1),V), - lookup(l(B,M2,C2),V). -get_constraint(l(N,p(A),p(B)),V):- - X1 = X2, - M = 10000000, - Y1 = M * X1 + C, - lookup(l(N,M,C),V), - lookup(p(A,X1,Y1),V), - lookup(p(B,X2,Y2),V). -get_constraint(l(N,p(A),p(B)),V):- - Y1 = M * X1 + C, - Y2 = M * X2 + C, - neq_r(X1,X2), - lookup(l(N,M,C),V), - lookup(p(A,X1,Y1),V), - lookup(p(B,X2,Y2),V). -get_constraint(p(_,xy(_,_)),_). -get_constraint(l(_,mc(_,_)),_). - -neq_r(X,Y):- Y > X . -neq_r(X,Y):- X > Y . - -make_db([p(N,X,Y)|T],DB,[p(N,X,Y)|EDB]):- - make_db(T,DB,EDB). -make_db([l(N,M,C)|T],DB,EDB):- - make_db(T,DB,EDB). -make_db([],DB,DB). - -geometry(X,DB):- - make_vars(X,[],V), - make_db(V,[],DB), - make_constraints(X,V). - -go:- geometry( - [ - p(1,xy(10,10)), - p(2,xy(10,20)), - p(3,xy(20,10)), - p(4,xy(20,20)), - l(1,p(1),p(4)), - l(2,p(2),p(3)), - p(5,l(1),l(2)) - ], - DB - ), - path( - [ - p(1), - p(2), - p(5), - p(1) - ], - DB - ). - -% Output: -% G00 X10.000 Y10.000 -% G01 X10.000 Y20.000 -% G01 X15.000 Y15.000 -% G01 X10.000 Y10.000 - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/monash/zebra b/CLPQR/clpqr/examples/monash/zebra deleted file mode 100644 index 32b06bb22..000000000 --- a/CLPQR/clpqr/examples/monash/zebra +++ /dev/null @@ -1,62 +0,0 @@ - -/* - ********************************************************************** - * - * CLP(R) Version 2.0 (Example Programs Release) - * (C) Copyright, March 1986, Monash University - * - ********************************************************************** - */ - -% -% A program to solve the Zebra Puzzle. -% - -zebra(Zebraowner,Drinkswater) :- - houses(s(s(s(s(s(zero))))), List), - member(house( red, englishman, _, _, _) ,List), - member(house( _, spaniard, dog, _, _) ,List), - member(house(green, _, _, coffee, _) ,List), - member(house( _, ukrainian, _, tea, _) ,List), - sublist([house(ivory, _, _, _, _) , - house(green, _, _, _, _)],List), - member(house( _, _,snail, _,old_gold),List), - member(house(yellow, _, _, _, kools),List), - eq([H1,H2,house( _, _, _, milk, _),H4,H5], List), - eq([house( _, norwegian, _, _, _)|Hrest], List), - nextto(house( _, _, _, _,chesterfield), - house( _, _, fox, _, _),List), - nextto(house( _, _, _, _, kools), - house( _, _,horse, _, _),List), - member(house( _, _, _, orange,lucky_strike),List), - member(house( _, japanese, _, _,parliaments),List), - nextto(house( _, norwegian, _, _, _), - house( blue, _, _, _, _),List), - member(house( _, Drinkswater, _, water, _),List), - member(house( _, Zebraowner,zebra, _, _),List). - -eq(X, X). - -houses(zero, []). -houses(s(N), [house(Color,Nat,Pet,Drink,Cig)|List]) :- houses(N, List). - -member(X, [X|R]). -member(X, [Y|R]) :- member(X, R). - -sublist(S, L) :- append(S, S2, L). -sublist(S, [H|T]) :- sublist(S, T). - -append([], L, L). -append([X|R], Y, [X|T]) :- append(R, Y, T). - -nextto(H1, H2, L) :- sublist([H1, H2], L). -nextto(H1, H2, L) :- sublist([H2, H1], L). - -go :- - zebra(Zebraowner, Drinkwater), - printf("Zebraowner = %, Drinkwater = %\n", [Zebraowner, Drinkwater]). - -% Answer: -% Zebraowner = japanese, Drinkwater = norwegian - -?- printf("\n>>> Sample goal: go/0\n", []). diff --git a/CLPQR/clpqr/examples/root.pl b/CLPQR/clpqr/examples/root.pl deleted file mode 100644 index 5c0d8877a..000000000 --- a/CLPQR/clpqr/examples/root.pl +++ /dev/null @@ -1,106 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: root.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% perform N iterations of the sqrt(2) newton approx. -% -root( N, R) :- - root( N, 1, R). - -root( 0, S, R) :- !, S=R. -root( N, S, R) :- - N1 is N-1, - { S1 = S/2 + 1/S }, - root( N1, S1, R). - -% -% print e with a precision of at least N digits after 2. -% -e( N) :- - e( N, E), - print_decimal( E, N). - -e( N, E) :- - { Err =:= exp(10,-(N+2)), Half =:= 1/2 }, - inv_e_series( Half, Half, 3, Err, Inv_E), - { E =:= 1/Inv_E }. - -inv_e_series( Term, S0, _, Err, Sum) :- - { abs(Term) =< Err }, - !, - S0 = Sum. -inv_e_series( Term, S0, N, Err, Sum) :- - N1 is N+1, - { Term1 =:= -Term/N, S1 =:= Term1+S0 }, - inv_e_series( Term1, S1, N1, Err, Sum). - -% -% print Rat with a precision of N places after the decimal point -% -print_decimal( Rat, N) :- - clpq:arith_eval( truncate( Rat), Int), Int=rat(I,1), - clpq:arith_eval( Rat-Int, Rest), - clpq:arith_eval( numer( Rest), rat(Num,1)), - clpq:arith_eval( denom( Rest), rat(Den,1)), - format( "~d.", [I]), - wdig( 0, N, Num, Den), - nl. - -wdig( N, M, _, _) :- N>=M, !. -wdig( _, _, 0, _) :- !. % finite decimal expansion -wdig( I, N, A, B) :- - I1 is I+1, - D is (10*A) // B, - A1 is (10*A) mod B, - ( I mod 10 =:= 0 -> put(" ") ; true ), - ( I mod 70 =:= 0 -> nl, tab(2) ; true), - write( D), - wdig( I1, N, A1, B). - -% -% Collect n digits of the decimal expansion of a/b -% where a//b = 0 -% -dig( 0, _, _, []) :- !. -dig( _, 0, _, []) :- !. % finite decimal expansion -dig( I, A, B, [D|Ds]) :- - I1 is I-1, - A10 is 10*A, - D is A10 // B, - A1 is A10 mod B, - dig( I1, A1, B, Ds). - -/* -| ?- time(expo(1000)). -2. - 7182818284 5904523536 0287471352 6624977572 4709369995 9574966967 6277240766 - 3035354759 4571382178 5251664274 2746639193 2003059921 8174135966 2904357290 - 0334295260 5956307381 3232862794 3490763233 8298807531 9525101901 1573834187 - 9307021540 8914993488 4167509244 7614606680 8226480016 8477411853 7423454424 - 3710753907 7744992069 5517027618 3860626133 1384583000 7520449338 2656029760 - 6737113200 7093287091 2744374704 7230696977 2093101416 9283681902 5515108657 - 4637721112 5238978442 5056953696 7707854499 6996794686 4454905987 9316368892 - 3009879312 7736178215 4249992295 7635148220 8269895193 6680331825 2886939849 - 6465105820 9392398294 8879332036 2509443117 3012381970 6841614039 7019837679 - 3206832823 7646480429 5311802328 7825098194 5581530175 6717361332 0698112509 - 9618188159 3041690351 5988885193 4580727386 6738589422 8792284998 9208680582 - 5749279610 4841984443 6346324496 8487560233 6248270419 7862320900 2160990235 - 3043699418 4914631409 3431738143 6405462531 5209618369 0888707016 7683964243 - 7814059271 4563549061 3031072085 1038375051 0115747704 1718986106 8739696552 - 1267154688 9570350354 -%%% Timing 00:01:29.150 89.150 -*/ - - - - diff --git a/CLPQR/clpqr/examples/simplex.pl b/CLPQR/clpqr/examples/simplex.pl deleted file mode 100644 index 5f3226a9b..000000000 --- a/CLPQR/clpqr/examples/simplex.pl +++ /dev/null @@ -1,337 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: simplex.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% b152 p.32 40/160/17200 -example( 1, [X1,X2], Z) :- - { - X1=<50, - X2=<200, - X1+0.2*X2=<72, - 150*X1+25*X2=<10000, - Z = 250*X1+45*X2 - }, - maximize(Z). - -% p.33 1/0/1.5/7 -example( 2,[X1,X2,X3], Z) :- - { - X1=<2, - X1+X2+2*X3=<4, - 3*X2+4*X3=<6, - X1>=0, - X2>=0, - X3>=0, - Z = X1+2*X2+4*X3 - }, - maximize(Z). - -% p.38 38/170/18850 -example( 3, [X1,X2], Z) :- - { - X1=<50, - X2=<200, - X1+0.2*X2=<72, - 150*X1+25*X2=<10000, - 10*X1+X2>=550, - Z = 250*X1+55*X2 - }, - maximize(Z). - -% 7/2/310 -example( 4, [X,Y], Z) :- - { - 2*X+Y =< 16, - X+2*Y =< 11, - X+3*Y =< 15, - Z = 30*X+50*Y - }, - maximize(Z). - -% b30313 p.315 0/0/2.5/5 -example( 5, [X,Y,Z], Min) :- - { - X+3*Y+2*Z >= 5, - 2*X+2*Y+Z >= 2, - 4*X-2*Y+3*Z >= -1, - X >= 0, - Y >= 0, - Z >= 0, - Min = 6*X+5*Y+2*Z - }, - minimize(Min). - -% -7 -example( 6, [X1,X2,X3], Min) :- - { - X1=<2, - X1+X2+2*X3=<4, - 3*X2+4*X3=<6, - X1>=0, - X2>=0, - X3>=0, - Min = -X1-2*X2-4*X3 - }, - minimize( Min). - -% -70 -example( 7, [X1,X2,X3,X4,X5,X6,X7], Min) :- - { - X1 + X3 - X4 + X5 + 2*X6 + X7 =< 6, - X2 + X4 - 2*X5 + X6 - 2*X7 =< 4, - X3 - X4 + 2*X6 + X7 =< 1, - - 0 =< X1, X1 =< 6, - 0 =< X2, X2 =< 6, - 0 =< X3, - 0 =< X4, X4 =< 4, - 0 =< X5, X5 =< 2, - 0 =< X6, X6 =< 10, - 0 =< X7, - Min = -3*X1 + 4*X2 + 2*X3 - 2*X4 - 14*X5 + 11*X6 - 5*X7 - }, - minimize( Min). - -% -39/2 -example( 8, [X1,X2,X3,X4,X5,X6,X7], Min) :- - { - X1 + X3 - X4 + X5 + 2*X6 + X7 =< 6, - X2 + X4 - 2*X5 + X6 - 2*X7 =< 4, - X3 - X4 + 2*X6 + X7 =< 1, - - 0 =< X1, X1 =< 6, - 0 =< X2, X2 =< 6, - 0 =< X3, - 0 =< X4, X4 =< 4, - 0 =< X5, X5 =< 2, - 0 =< X6, X6 =< 10, - 0 =< X7, - Min = 3*X1 - 4*X2 - 2*X3 + 2*X4 + 14*X5 - 11*X6 + 5*X7 - }, - minimize( Min). - -% -% min = 11429082625/9792 = 1167185.7255923203 -% -example( 9, Vs, Obj) :- - - Vs = [ Anm1,Anm2,Anm3,Anm4,Anm5,Anm6, - Stm1,Stm2,Stm3,Stm4,Stm5,Stm6, - UE1,UE2,UE3,UE4,UE5,UE6 - ], - - allpos( Vs), - { - +1*Stm1 = 60, - +0.9*Stm1 +1*Anm1 -1*Stm2 = 0, - +0.9*Stm2 +1*Anm2 -1*Stm3 = 0, - +0.9*Stm3 +1*Anm3 -1*Stm4 = 0, - +0.9*Stm4 +1*Anm4 -1*Stm5 = 0, - +0.9*Stm5 +1*Anm5 -1*Stm6 = 0, - +150*Stm1 -100*Anm1 +1*UE1 >= 8000, - +150*Stm2 -100*Anm2 +1*UE2 >= 9000, - +150*Stm3 -100*Anm3 +1*UE3 >= 8000, - +150*Stm4 -100*Anm4 +1*UE4 >= 10000, - +150*Stm5 -100*Anm5 +1*UE5 >= 9000, - +150*Stm6 -100*Anm6 +1*UE6 >= 12000, - -20*Stm1 +1*UE1 =< 0, - -20*Stm2 +1*UE2 =< 0, - -20*Stm3 +1*UE3 =< 0, - -20*Stm4 +1*UE4 =< 0, - -20*Stm5 +1*UE5 =< 0, - -20*Stm6 +1*UE6 =< 0, - Anm1 =< 18, - 57 =< Stm2, - Stm2 =< 75, - Anm2 =< 18, - 57 =< Stm3, - Stm3 =< 75, - Anm3 =< 18, - 57 =< Stm4, - Stm4 =< 75, - Anm4 =< 18, - 57 =< Stm5, - Stm5 =< 75, - Anm5 =< 18, - 57 =< Stm6, - Stm6 =< 75, - Anm6 =< 18, - - Obj = +2700*Stm1 +1500*Anm1 +30*UE1 - +2700*Stm2 +1500*Anm2 +30*UE2 - +2700*Stm3 +1500*Anm3 +30*UE3 - +2700*Stm4 +1500*Anm4 +30*UE4 - +2700*Stm5 +1500*Anm5 +30*UE5 - +2700*Stm6 +1500*Anm6 +30*UE6 - }, - minimize( Obj). - - -% b20011, p144 -% -example( utility, Vs, Min) :- - - Vs = [ X11, X12, X13, X14, X15, - X21, X22, X23, X24, X25, - Y11, Y12, Y13, Y14, - Y21, Y22, Y23, Y24, Y25, - Z11, Z12, Z13, Z14, - Z21, Z22, Z23, Z24, Z25], - { - X11 + X12 + X13 + X14 + X15 = 1000, - X21 + X22 + X23 + X24 + X25 = 1000, - - 3*X11 + 2*X21 - Y11 - Y14 - Z11 - Z14 =< 0, - -3*X12 - 2*X22 + Y11 - Y12 + Z11 - Z12 = 0, - -3*X13 - 2*X23 - Y13 + Y14 - Z13 + Z14 = 0, - -3*X14 - 2*X24 + Y12 + Z12 = 0, - -3*X15 - 2*X25 + Y13 + Z13 = 0, - - 4*X11 + 5*X21 - Y21 - Z21 =< 0, - -4*X12 - 5*X22 + Y22 + Z22 = 0, - -4*X13 - 5*X23 + Y24 - Y25 + Z24 - Z25 = 0, - -4*X14 - 5*X24 + Y21 - Y22 - Y23 + Y25 - + Z21 - Z22 - Z23 + Z25 = 0, - -4*X15 - 5*X25 + Y23 - Y24 + Z23 - Z24 = 0, - - 7*X11 + 9*X21 >= 0, - 7*X12 + 9*X22 =< 3000, - 7*X13 + 9*X23 =< 200, - 7*X14 + 9*X24 =< 10000, - 7*X15 + 9*X25 =< 7000, - - Z11 =< 1000, - Z12 =< 500, - Z13 =< 2000, - Z14 =< 100, - Z21 =< 5000, - Z22 =< 250, - Z23 =< 600, - Z24 =< 7000, - Z25 =< 4000, - - X11 >= 0, X12 >= 0, X13 >= 0, X14 >= 0, X15 >= 0, - X21 >= 0, X22 >= 0, X23 >= 0, X24 >= 0, X25 >= 0, - - Y11 >= 0, Y12 >= 0, Y13 >= 0, Y14 >= 0, - Y21 >= 0, Y22 >= 0, Y23 >= 0, Y24 >= 0, Y25 >= 0, - - Z11 >= 0, Z12 >= 0, Z13 >= 0, Z14 >= 0, - Z21 >= 0, Z22 >= 0, Z23 >= 0, Z24 >= 0, Z25 >= 0, - - M = 99999, - Min = M*X11 + M*X21 + 3*Y11 + 7*Y12 + 9*Y13 + Y14 + 4*Y21 + 7*Y22 + 3*Y23 + - 8*Y24 + 5*Y25 - }, - minimize(Min). - -example( electricity, Vs, Min) :- - - Vs = [ X11, X12, X13, X14, X15, - X21, X22, X23, X24, X25, - Y11, Y12, Y13, Y14, - Z11, Z12, Z13, Z14], - { - X11 + X12 + X13 + X14 + X15 = 1000, - X21 + X22 + X23 + X24 + X25 = 1000, - - 3*X11 + 2*X21 - Y11 - Y14 - Z11 - Z14 =< 0, - -3*X12 - 2*X22 + Y11 - Y12 + Z11 - Z12 = 0, - -3*X13 - 2*X23 - Y13 + Y14 - Z13 + Z14 = 0, - -3*X14 - 2*X24 + Y12 + Z12 = 0, - -3*X15 - 2*X25 + Y13 + Z13 = 0, - - 7*X11 + 9*X21 >= 0, - 7*X12 + 9*X22 =< 3000, - 7*X13 + 9*X23 =< 200, - 7*X14 + 9*X24 =< 10000, - 7*X15 + 9*X25 =< 7000, - - Z11 =< 1000, - Z12 =< 500, - Z13 =< 2000, - Z14 =< 100, - - X11 >= 0, X12 >= 0, X13 >= 0, X14 >= 0, X15 >= 0, - X21 >= 0, X22 >= 0, X23 >= 0, X24 >= 0, X25 >= 0, - Y11 >= 0, Y12 >= 0, Y13 >= 0, Y14 >= 0, - Z11 >= 0, Z12 >= 0, Z13 >= 0, Z14 >= 0, - - M = 99999, - Min = M*X11 + M*X21 + 3*Y11 + 7*Y12 + 9*Y13 + Y14 - }, - minimize(Min). - -example( water, Vs, Min) :- - - Vs = [ X11, X12, X13, X14, X15, - X21, X22, X23, X24, X25, - Y21, Y22, Y23, Y24, Y25, - Z21, Z22, Z23, Z24, Z25], - { - X11 + X12 + X13 + X14 + X15 = 1000, - X21 + X22 + X23 + X24 + X25 = 1000, - - 4*X11 + 5*X21 - Y21 - Z21 =< 0, - -4*X12 - 5*X22 + Y22 + Z22 = 0, - -4*X13 - 5*X23 + Y24 - Y25 + Z24 - Z25 = 0, - -4*X14 - 5*X24 + Y21 - Y22 - Y23 + Y25 - + Z21 - Z22 - Z23 + Z25 = 0, - -4*X15 - 5*X25 + Y23 - Y24 + Z23 - Z24 = 0, - - 7*X11 + 9*X21 >= 0, - 7*X12 + 9*X22 =< 3000, - 7*X13 + 9*X23 =< 200, - 7*X14 + 9*X24 =< 10000, - 7*X15 + 9*X25 =< 7000, - - Z21 =< 5000, - Z22 =< 250, - Z23 =< 600, - Z24 =< 7000, - Z25 =< 4000, - - X11 >= 0, X12 >= 0, X13 >= 0, X14 >= 0, X15 >= 0, - X21 >= 0, X22 >= 0, X23 >= 0, X24 >= 0, X25 >= 0, - - Y21 >= 0, Y22 >= 0, Y23 >= 0, Y24 >= 0, Y25 >= 0, - - Z21 >= 0, Z22 >= 0, Z23 >= 0, Z24 >= 0, Z25 >= 0, - - M = 99999, - Min = M*X11 + M*X21 + 4*Y21 + 7*Y22 + 3*Y23 + 8*Y24 + 5*Y25 - }, - minimize(Min). - -allpos( []). -allpos( [V|Vs]) :- - { V >= 0 }, - allpos( Vs). - -% -------------------------------------------------------------------------- - -test(0) :- { A=<2,B=<3,C=<4,A+B+C=10 }. % must fail - -test(5) :- - { - 2*X1 + 4*X2 + 3*X3 - 4*W1 - 10*W2 = 0, - 2*X1 + X2 + X3 = 4, - 5*X1 + 3*X2 + 2*X3 = 10, - 2*W1 + 5*W2 =< 2, - W1 + 3*W2 =< 4, - W1 + 2*W2 =< 3, - X1 >= 0, - X2 >= 0, - X3 >= 0 - }. - - diff --git a/CLPQR/clpqr/examples/squares.pl b/CLPQR/clpqr/examples/squares.pl deleted file mode 100644 index a60e4e9c5..000000000 --- a/CLPQR/clpqr/examples/squares.pl +++ /dev/null @@ -1,108 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: squares.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -/* -This beautiful example of disequations at work is due -to [Colmerauer 90]. It addresses the task of tiling a rectangle -with squares of all-different, a priori unknown sizes. Here is a -translation of the original Prolog-III program to clp(q,r) - -[Colmerauer 90] - Colmerauer A.: An Introduction to Prolog III, - Communications of the ACM, 33(7), 69-90, 1990. - - - - -| ?- length(L,9),filled_rectangle(A,L). - -A = 33/32, -L = [15/32,9/16,1/4,7/32,1/8,7/16,1/32,5/16,9/32] ? ; - -A = 69/61, -L = [33/61,36/61,28/61,5/61,2/61,9/61,25/61,7/61,16/61] ? -*/ - - -rectangle( A, Rs) :- - Rs = [X1,X2,X3,X4,X5,X6,X7,X8,X9], - filled_rectangle( A, Rs). - -filled_rectangle( A, C) :- - { A >= 1 }, - distinct_squares( C), % also acts as generator [], [_], [_,_], ... - filled_zone( [-1,A,1], _, C, []). - -distinct_squares( []). -distinct_squares( [B|C]) :- - { B > 0 }, - outof( C, B), - distinct_squares( C). - -outof( [], _). -outof( [B1|C], B) :- - { B =\= B1 }, - outof( C, B). - -filled_zone( [V|L], [V|L], C0, C0) :- - { V >= 0 }. -filled_zone( [V|L], L3, [B|C], C2) :- - { V < 0 }, - placed_square( B, L, L1), - filled_zone( L1, L2, C, C1), - { Vb=V+B }, - filled_zone( [Vb,B|L2], L3, C1, C2). - -placed_square( B, [H,H0,H1|L], L1) :- - { B > H, H0=0, H2=H+H1 }, - placed_square( B, [H2|L], L1). -placed_square( B, [B,V|L], [X|L]) :- - { X=V-B }. -placed_square( B, [H|L], [X,Y|L]) :- - { B < H, X= -B, Y=H-B }. - -% -% first nontrivial solution has 21 squares ... -% -perfect( S) :- - { A = 1 }, - distinct_squares( S), - length( S, Len), Len > 1, - print( try(Len)), nl, - flush_output, - time( filled_zone( [-1,A,1], _, S, [])). - -/* -try(2) -%%% Timing 00:00:00.030 0.030 -try(3) -%%% Timing 00:00:00.070 0.070 -try(4) -%%% Timing 00:00:00.270 0.270 -try(5) -%%% Timing 00:00:01.060 1.060 -try(6) -%%% Timing 00:00:04.470 4.470 -try(7) -%%% Timing 00:00:19.960 19.960 -try(8) -%%% Timing 00:01:33.380 93.380 -try(9) -%%% Timing 00:07:27.380 447.380 -try(10) -%%% Timing 00:37:03.770 2223.770 -try(11) -%%% Timing 03:11:38.380 11498.380 -try(12) -%%% Timing 16:18:43.110 58723.110 -*/ \ No newline at end of file diff --git a/CLPQR/clpqr/expand.pl b/CLPQR/clpqr/expand.pl deleted file mode 100644 index 046c08c56..000000000 --- a/CLPQR/clpqr/expand.pl +++ /dev/null @@ -1,196 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: expand.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Perform theory-purification in the presence of -% interpreted terms. -% - -:- module( expand, [expand/0, noexpand/0]). -:- dynamic expanding/0. - -:- multifile - user:term_expansion/2, - user:goal_expansion/3. - -:- dynamic - user:term_expansion/2, - user:goal_expansion/3. - -user:term_expansion(A,B) :- % expands heads - expanding, - purify_head(A,B). - -user:goal_expansion(G,M,E):- % expands bodies - M \== prolog, % quite common due to internal call_cleanups etc. - M \== expand, % this file may get loaded more than once - expanding, - purify(G,M,E). - -noexpand :- - retractall(expanding). - -expand :- - assert(expanding). - - -purify( Goal, Module, _) :- quoted( Goal, Module), !, fail. -purify( Goal, _, Expansion) :- - interpreted_relation( Goal, _Module), - !, - Expansion = {Goal}. -purify( X=Y, _Module, Expansion) :- !, % shortcut for =/2 - ( ( var(X) ; interpreted_term( X, Th) ), - ( var(Y) ; interpreted_term( Y, Th) ), - nonvar( Th) -> - Expansion = {X=Y} - ; - ra( X=Y, user, Pure, ThL, ThLTail), - ThL \== ThLTail, - ThLTail = [Pure], - l2conj( ThL, Expansion) - ). -purify( Goal, _Module, Expansion) :- - nobuiltin( Goal), - ra( Goal, user, Pure, ThL, ThLTail), - ThL \== ThLTail, % ifunctors present ? - ThLTail = [Pure], - l2conj( ThL, Expansion). - -nobuiltin( Goal) :- - predicate_property( Goal, built_in), - !, - fail. -nobuiltin( _). - -quoted( {_}, _). -quoted( run(_,_), geler). % late goal of verify_attributes/3 -quoted( resubmit_eq(_), nf). % some (all?) of its clients -quoted( resubmit_lt(_), nf). -quoted( resubmit_le(_), nf). -quoted( resubmit_ne(_), nf). -quoted( wait_linear_retry(_,_,_), nf). -quoted( fm_cp_filter(_,_,_), linear). % generator in findall/3 -% -quoted( printf(_), _). -quoted( printf(_,_), _). -quoted( user_tout(_,_,_,_), _). % undef pred - -% -% Identify the theory (module) involved. -% -interpreted_term( X, _) :- var(X), !, fail. -interpreted_term( X, linear) :- number(X). -interpreted_term( rat(_,_), linear). % rational constant -% -interpreted_term( #(_), linear). % Monash -interpreted_term( -(_), linear). % unary minus -interpreted_term( +(_), linear). % plus -interpreted_term( +(_,_), linear). % binary -interpreted_term( -(_,_), linear). -interpreted_term( *(_,_), linear). -interpreted_term( /(_,_), linear). -interpreted_term( pow(_,_), linear). -interpreted_term( exp(_,_), linear). -interpreted_term( ^(_,_), linear). -interpreted_term( sin(_), linear). -interpreted_term( cos(_), linear). -interpreted_term( tan(_), linear). -interpreted_term( min(_,_), linear). -interpreted_term( max(_,_), linear). -interpreted_term( abs(_), linear). - -interpreted_relation( G, _) :- var(G), !, fail. -interpreted_relation( <(_,_), linear). -interpreted_relation( =<(_,_), linear). -interpreted_relation( <=(_,_), linear). % Monash -interpreted_relation( >(_,_), linear). -interpreted_relation( >=(_,_), linear). -interpreted_relation( =\=(_,_), linear). -interpreted_relation( =:=(_,_), linear). - -% ---------------------------------------------------------------- - -% -% replace alien subterms by variables -% Special treatment for quote/1 -% -% -% -ra( Term, _, Pure) --> {var(Term), !, Term = Pure}. -ra( Term, Th, Pure) --> - { - functor( Term, N, A), - functor( Pure, N, A) - }, - ra( A, Term, Th, Pure). - -ra( 0, _, _, _) --> !. -ra( N, Term, Th, Pure) --> - { - N1 is N-1, - arg( N, Term, Ta), - arg( N, Pure, Pa) - }, - ra_one( Ta, Th, Pa), - ra( N1, Term, Th, Pure). - -ra_one( Term, _, Pure) --> {var( Term), !, Pure=Term}. -ra_one( quote(Term), _, Pure) --> {!, Pure=Term}. -ra_one( Term, ParentTheory, Pure) --> - { - ( interpreted_term( Term, Theory) -> - true - ; - Theory=user - ) - }, - ( { ParentTheory=Theory } -> - ra( Term, Theory, Pure) - ; - ra_equate( Theory, Pure, ThPure), - ra( Term, Theory, ThPure) - ). - -ra_equate( user, A, B) --> !, { A=B }. % now -ra_equate( _Theory, A, B) --> [ {A=B} ]. % later - -% --------------------------------------------------------------------------- - -purify_head( Term, NewTerm) :- - ( prolog:dcg_expansion( Term, []/*undef layout*/, Exp, _) -> - true - ; - Term = Exp - ), - ( Exp = ?-(_) -> % don't touch these - fail - ; Exp = :-(_) -> % expanded via goal_expansion - fail - ; Exp = (H:-B) -> - ra( H, user, NewHead, Cl, []), - Cl = [_|_], % ifunctors in head ? - l2conj( Cl, Thc), - NewTerm = (NewHead:-Thc,B) - ; % facts - ra( Exp, user, H, Cl, []), - Cl = [_|_], % ifunctors in head ? - l2conj( Cl, B), - NewTerm = (H:-B) - ). - -l2conj( [], true). -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). diff --git a/CLPQR/clpqr/expand.yap b/CLPQR/clpqr/expand.yap deleted file mode 100644 index 0866dc4ca..000000000 --- a/CLPQR/clpqr/expand.yap +++ /dev/null @@ -1,199 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: expand.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Perform theory-purification in the presence of -% interpreted terms. -% - -:- module( expand, [expand/0, noexpand/0]). -:- dynamic expanding/0. - -:- multifile - user:term_expansion/2, - user:goal_expansion/3. - -:- dynamic - user:term_expansion/2, - user:goal_expansion/3. - -user:term_expansion(A,B) :- % expands heads - expanding, - purify_head(A,B). - -user:goal_expansion(G,M,E):- % expands bodies - M \== prolog, % quite common due to internal call_cleanups etc. - M \== expand, % this file may get loaded more than once - expanding, - purify(G,M,E). - -noexpand :- - retractall(expanding). - -expand :- - assert(expanding). - - -purify( Goal, Module, _) :- quoted( Goal, Module), !, fail. -purify( Goal, _, Expansion) :- - interpreted_relation( Goal, _Module), - !, - Expansion = {Goal}. -purify( X=Y, _Module, Expansion) :- !, % shortcut for =/2 - ( ( var(X) ; interpreted_term( X, Th) ), - ( var(Y) ; interpreted_term( Y, Th) ), - nonvar( Th) -> - Expansion = {X=Y} - ; - ra( X=Y, user, Pure, ThL, ThLTail), - ThL \== ThLTail, - ThLTail = [Pure], - l2conj( ThL, Expansion) - ). -purify( Goal, _Module, Expansion) :- - nobuiltin( Goal), - ra( Goal, user, Pure, ThL, ThLTail), - ThL \== ThLTail, % ifunctors present ? - ThLTail = [Pure], - l2conj( ThL, Expansion). - -nobuiltin( Goal) :- - predicate_property( Goal, built_in), - !, - fail. -nobuiltin( _). - -quoted( {_}, _). -quoted( run(_,_), geler). % late goal of verify_attributes/3 -quoted( resubmit_eq(_), nf). % some (all?) of its clients -quoted( resubmit_lt(_), nf). -quoted( resubmit_le(_), nf). -quoted( resubmit_ne(_), nf). -quoted( wait_linear_retry(_,_,_), nf). -quoted( fm_cp_filter(_,_,_), linear). % generator in findall/3 -% -quoted( printf(_), _). -quoted( printf(_,_), _). -quoted( user_tout(_,_,_,_), _). % undef pred - -% -% Identify the theory (module) involved. -% -interpreted_term( X, _) :- var(X), !, fail. -interpreted_term( X, linear) :- number(X). -interpreted_term( rat(_,_), linear). % rational constant -% -interpreted_term( #(_), linear). % Monash -interpreted_term( -(_), linear). % unary minus -interpreted_term( +(_), linear). % plus -interpreted_term( +(_,_), linear). % binary -interpreted_term( -(_,_), linear). -interpreted_term( *(_,_), linear). -interpreted_term( /(_,_), linear). -interpreted_term( pow(_,_), linear). -interpreted_term( exp(_,_), linear). -interpreted_term( ^(_,_), linear). -interpreted_term( sin(_), linear). -interpreted_term( cos(_), linear). -interpreted_term( tan(_), linear). -interpreted_term( min(_,_), linear). -interpreted_term( max(_,_), linear). -interpreted_term( abs(_), linear). - -interpreted_relation( G, _) :- var(G), !, fail. -interpreted_relation( <(_,_), linear). -interpreted_relation( =<(_,_), linear). -interpreted_relation( <=(_,_), linear). % Monash -interpreted_relation( >(_,_), linear). -interpreted_relation( >=(_,_), linear). -interpreted_relation( =\=(_,_), linear). -interpreted_relation( =:=(_,_), linear). - -% ---------------------------------------------------------------- - -% -% replace alien subterms by variables -% Special treatment for quote/1 -% -% -% -ra( Term, _, Pure) --> {var(Term), !, Term = Pure}. -ra( Term, Th, Pure) --> - { - functor( Term, N, A), - functor( Pure, N, A) - }, - ra( A, Term, Th, Pure). - -ra( 0, _, _, _) --> !. -ra( N, Term, Th, Pure) --> - { - N1 is N-1, - arg( N, Term, Ta), - arg( N, Pure, Pa) - }, - ra_one( Ta, Th, Pa), - ra( N1, Term, Th, Pure). - -ra_one( Term, _, Pure) --> {var( Term), !, Pure=Term}. -ra_one( quote(Term), _, Pure) --> {!, Pure=Term}. -ra_one( Term, ParentTheory, Pure) --> - { - ( interpreted_term( Term, Theory) -> - true - ; - Theory=user - ) - }, - ( { ParentTheory=Theory } -> - ra( Term, Theory, Pure) - ; - ra_equate( Theory, Pure, ThPure), - ra( Term, Theory, ThPure) - ). - -ra_equate( user, A, B) --> !, { A=B }. % now -ra_equate( _Theory, A, B) --> [ {A=B} ]. % later - -% --------------------------------------------------------------------------- - -purify_head( Term, NewTerm) :- -% vsc: doesn't really exist in YAP, ignore it for now. -% ( prolog:dcg_expansion( Term, []/*undef layout*/, Exp, _) -> -% true -% ; -% Term = Exp -% ), - Term = Exp, - ( Exp = ?-(_) -> % don't touch these - fail - ; Exp = :-(_) -> % expanded via goal_expansion - fail - ; Exp = (H:-B) -> - ra( H, user, NewHead, Cl, []), - Cl = [_|_], % ifunctors in head ? - l2conj( Cl, Thc), - NewTerm = (NewHead:-Thc,B) - ; % facts - ra( Exp, user, H, Cl, []), - Cl = [_|_], % ifunctors in head ? - l2conj( Cl, B), - NewTerm = (H:-B) - ). - -l2conj( [], true). -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - diff --git a/CLPQR/clpqr/fourmotz.pl b/CLPQR/clpqr/fourmotz.pl deleted file mode 100644 index c0dd77f29..000000000 --- a/CLPQR/clpqr/fourmotz.pl +++ /dev/null @@ -1,294 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: fourmotz.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% TODO -) remove syntactic redundancy first ?!! -% -) avoid the construction of the crossproduct list -% +) consider strictness in crossproduct generation !!! -% - -fm_elim( Vs, Target, Pivots) :- - prefilter( Vs, Vsf), - fm_elim_int( Vsf, Target, Pivots). - -prefilter( [], []). -prefilter( [V|Vs], Res) :- - ( get_atts( V, -target), - occurs( V) -> - Res = [V|Tail], - put_atts( V, keep_indep), - prefilter( Vs, Tail) - ; - prefilter( Vs, Res) - ). - -% -% the target variables are marked with an attribute, and we get a list -% of them as an argument too -% -fm_elim_int( [], _, Pivots) :- % done - unkeep( Pivots). -fm_elim_int( Vs, Target, Pivots) :- - Vs = [_|_], - ( best( Vs, Best, Rest) -> - occurences( Best, Occ), - elim_min( Best, Occ, Target, Pivots, NewPivots) - ; % give up - NewPivots=Pivots, Rest = [] - ), - fm_elim_int( Rest, Target, NewPivots). - -% -% Find the variable with the smallest netto increase on the -% size of the ineq. system after its elimination -% -best( Vs, Best, Rest) :- - findall( Delta-N, fm_cp_filter( Vs, Delta, N), Deltas), - keysort( Deltas, [_-N|_]), - select_nth( Vs, N, Best, Rest). - -fm_cp_filter( Vs, Delta, N) :- - length( Vs, Len), - mem( Vs,X,Vst), - get_atts( X, [-target,lin(Lin)]), - indep( Lin, X), - occurences( X, Occ), - Occ = [_|_], - % crossproduct( Occ, New, []), - % length( New, CpLnew), - cp_card( Occ, 0,Lnew), - length( Occ, Locc), - Delta is Lnew-Locc, - length( Vst, Vstl), - N is Len-Vstl. - -mem( [X|Xs], X, Xs). -mem( [_|Ys], X, Xs) :- mem( Ys, X, Xs). - -select_nth( List, N, Nth, Others) :- - select_nth( List, 1,N, Nth, Others). - -select_nth( [X|Xs], N,N, X, Xs) :- !. -select_nth( [Y|Ys], M,N, X, [Y|Xs]) :- - M1 is M+1, - select_nth( Ys, M1,N, X, Xs). - -% -% fm_detach + reverse_pivot introduce indep t_none, which -% invalidates the invariants -% -elim_min( V, Occ, Target, Pivots, NewPivots) :- - crossproduct( Occ, New, []), - activate_crossproduct( New), - reverse_pivot( Pivots), - fm_detach( Occ), - % length( Occ, Locc), length( New, Lnew), print( fm(-Locc,+Lnew)), nl, - allvars( V, All), - redundancy_vars( All), % only for New \== [] - make_target_indep( Target, NewPivots), - drop_dep( All). - -% -% restore NF by reverse pivoting -% -reverse_pivot( []). -reverse_pivot( [I:D|Ps]) :- - get_atts( D, type(Dt)), - put_atts( D, -keep), % no longer - pivot( D, I, Dt), - reverse_pivot( Ps). - -unkeep( []). -unkeep( [_:D|Ps]) :- - put_atts( D, -keep), - drop_dep_one( D), - unkeep( Ps). - - -% -% All we drop are bounds -% -fm_detach( []). -fm_detach( [V:_|Vs]) :- - detach_bounds( V), - fm_detach( Vs). - -% -% Todo: maybe bulk_basis_add -% -activate_crossproduct( []). -activate_crossproduct( [lez(Strict,Lin)|News]) :- - arith_eval( 0, Z), - var_with_def_intern( t_u(Z), Var, Lin, Strict), - basis_add( Var, _), - activate_crossproduct( News). - -% ------------------------------------------------------------------------------ - -crossproduct( []) --> []. -crossproduct( [A|As]) --> - crossproduct( As, A), - crossproduct( As). - -crossproduct( [], _) --> []. -crossproduct( [B:Kb|Bs], A:Ka) --> - { - get_atts( A, [type(Ta),lin(LinA),strictness(Sa)]), - get_atts( B, [type(Tb),lin(LinB),strictness(Sb)]), - arith_eval( -Kb/Ka, K), - add_linear_f1( LinA, K, LinB, Lin) - }, - ( { arith_eval( K > 0) } -> % signs were opposite - { Strict is Sa \/ Sb }, - cross_lower( Ta, Tb, K, Lin, Strict), - cross_upper( Ta, Tb, K, Lin, Strict) - ; % La =< A =< Ua -> -Ua =< -A =< -La - { - flip( Ta, Taf), - flip_strict( Sa, Saf), - Strict is Saf \/ Sb - }, - cross_lower( Taf, Tb, K, Lin, Strict), - cross_upper( Taf, Tb, K, Lin, Strict) - ), - crossproduct( Bs, A:Ka). - -cross_lower( Ta, Tb, K, Lin, Strict) --> - { - lower( Ta, La), - lower( Tb, Lb), - !, - arith_eval(K*La+Lb,L), - normalize_scalar( L, Ln), - arith_eval( -1, Mone), - add_linear_f1( Lin, Mone, Ln, Lhs), - Sl is Strict >> 1 % normalize to upper bound - }, - [ lez(Sl,Lhs) ]. -cross_lower( _, _, _, _, _) --> []. - -cross_upper( Ta, Tb, K, Lin, Strict) --> - { - upper( Ta, Ua), - upper( Tb, Ub), - !, - arith_eval(-(K*Ua+Ub),U), - normalize_scalar( U, Un), - add_linear_11( Un, Lin, Lhs), - Su is Strict /\ 2'01 % normalize to upper bound - }, - [ lez(Su,Lhs) ]. -cross_upper( _, _, _, _, _) --> []. - -lower( t_l(L), L). -lower( t_lu(L,_), L). -lower( t_L(L), L). -lower( t_Lu(L,_), L). -lower( t_lU(L,_), L). - -upper( t_u(U), U). -upper( t_lu(_,U), U). -upper( t_U(U), U). -upper( t_Lu(_,U), U). -upper( t_lU(_,U), U). - -flip( t_l(X), t_u(X)). -flip( t_u(X), t_l(X)). -flip( t_lu(X,Y),t_lu(Y,X)). -flip( t_L(X), t_u(X)). -flip( t_U(X), t_l(X)). -flip( t_lU(X,Y),t_lu(Y,X)). -flip( t_Lu(X,Y),t_lu(Y,X)). - -flip_strict( 2'00, 2'00). -flip_strict( 2'01, 2'10). -flip_strict( 2'10, 2'01). -flip_strict( 2'11, 2'11). - -cp_card( [], Ci,Ci). -cp_card( [A|As], Ci,Co) :- - cp_card( As, A, Ci,Cii), - cp_card( As, Cii,Co). - -cp_card( [], _, Ci,Ci). -cp_card( [B:Kb|Bs], A:Ka, Ci,Co) :- - get_atts( A, type(Ta)), - get_atts( B, type(Tb)), - arith_eval( -Kb/Ka, K), - ( arith_eval( K > 0) -> % signs were opposite - cp_card_lower( Ta, Tb, Ci,Cii), - cp_card_upper( Ta, Tb, Cii,Ciii) - ; - flip( Ta, Taf), - cp_card_lower( Taf, Tb, Ci,Cii), - cp_card_upper( Taf, Tb, Cii,Ciii) - ), - cp_card( Bs, A:Ka, Ciii,Co). - -cp_card_lower( Ta, Tb, Si,So) :- - lower( Ta, _), - lower( Tb, _), - !, - So is Si+1. -cp_card_lower( _, _, Si,Si). - -cp_card_upper( Ta, Tb, Si,So) :- - upper( Ta, _), - upper( Tb, _), - !, - So is Si+1. -cp_card_upper( _, _, Si,Si). - -% ------------------------------------------------------------------------------ - - - -occurences( V, Occ) :- - allvars( V, All), - occurences( All, V, Occ). - -occurences( De, _, []) :- var( De), !. -occurences( [D|De], V, Occ) :- - ( get_atts( D, [lin(Lin),type(Type)]), - occ_type_filter( Type), - nf_coeff_of( Lin, V, K) -> - Occ = [D:K|Occt], - occurences( De, V, Occt) - ; - occurences( De, V, Occ) - ). - -occ_type_filter( t_l(_)). -occ_type_filter( t_u(_)). -occ_type_filter( t_lu(_,_)). -occ_type_filter( t_L(_)). -occ_type_filter( t_U(_)). -occ_type_filter( t_lU(_,_)). -occ_type_filter( t_Lu(_,_)). - -% -% occurs( V) :- occurences( V, Occ), Occ = [_|_]. -% -occurs( V) :- - allvars( V, All), - occurs( All, V). - -occurs( De, _) :- var( De), !, fail. -occurs( [D|De], V) :- - ( get_atts( D, [lin(Lin),type(Type)]), - occ_type_filter( Type), - nf_coeff_of( Lin, V, _) -> - true - ; - occurs( De, V) - ). diff --git a/CLPQR/clpqr/ineq.pl b/CLPQR/clpqr/ineq.pl deleted file mode 100644 index 1456bb279..000000000 --- a/CLPQR/clpqr/ineq.pl +++ /dev/null @@ -1,984 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: ineq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Lin (=)< 0 -% -ineq( [], I, _, Strictness) :- ineq_ground( Strictness, I). -ineq( [v(K,[X^1])|Tail], I, Lin, Strictness) :- - ineq_cases( Tail, I, Lin, Strictness, X, K). - -ineq_cases( [], I, _, Strictness, X, K) :- - ineq_one( Strictness, X, K, I). -ineq_cases( [_|_], _, Lin, Strictness, _, _) :- - deref( Lin, Lind), % Id+Hd =< 0 - decompose( Lind, Hom, _, Inhom), - ineq_more( Hom, Inhom, Lind, Strictness). - -ineq_ground( strict, I) :- arith_eval( I < 0). -ineq_ground( nonstrict, I) :- arith_eval( I =< 0). - -% -% Special cases: k={+-}1,i=0 -% -ineq_one( strict, X, K, I) :- - ( arith_eval(K>0) -> - ( arith_eval(I=:=0) -> - ineq_one_s_p_0( X) - ; - arith_eval( I/K, Inhom), - ineq_one_s_p_i( X, Inhom) - ) - ; - ( arith_eval(I=:=0) -> - ineq_one_s_n_0( X) - ; - arith_eval( -I/K, Inhom), - ineq_one_s_n_i( X, Inhom) - ) - ). -ineq_one( nonstrict, X, K, I) :- - ( arith_eval(K>0) -> - ( arith_eval(I=:=0) -> - ineq_one_n_p_0( X) - ; - arith_eval( I/K, Inhom), - ineq_one_n_p_i( X, Inhom) - ) - ; - ( arith_eval(I=:=0) -> - ineq_one_n_n_0( X) - ; - arith_eval( -I/K, Inhom), - ineq_one_n_n_i( X, Inhom) - ) - ). - -/* -ineq_one( Strictness, X, K, I) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old( OrdX, K, I, Strictness, X, Ix). -ineq_one( Strictness, X, K, I) :- % new variable, nothing depends on it - arith_eval( -I/K, Bound), - ineq_one_new( Strictness, X, K, Bound). - -ineq_one_new( strict, X, K, Bound) :- - arith_eval( 1, One), - ( arith_eval( K < 0) -> - var_intern( t_l(Bound), X, 2'10) - ; - var_intern( t_u(Bound), X, 2'01) - ). -ineq_one_new( nonstrict, X, K, Bound) :- - arith_eval( 1, One), - ( arith_eval( K < 0) -> - var_intern( t_l(Bound), X, 2'00) - ; - var_intern( t_u(Bound), X, 2'00) - ). - - -ineq_one_old( [], K, I, Strictness, _X, Ix) :- - arith_eval( K*Ix+I, Inhom), - ineq_ground( Strictness, Inhom). -% -% here we would have the choice to bound X or Y -% -ineq_one_old( [Y*Ky|Tail], K, I, Strictness, X, Ix) :- - ( Tail = [], - arith_eval( K*Ky, Coeff), - arith_eval( -(K*Ix+I)/Coeff, Bound), - update_indep( Strictness, Y, Coeff, Bound) - ; Tail = [_|_], - arith_eval( -I/K, Bound), - update_dep( Strictness, X, K, Bound) - ). - -update_dep( strict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - udls( Type, X, Lin, Bound, Old) - ; - udus( Type, X, Lin, Bound, Old) - ). -update_dep( nonstrict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - udl( Type, X, Lin, Bound, Old) - ; - udu( Type, X, Lin, Bound, Old) - ). -*/ - -% --------------------------- strict ---------------------------- - -ineq_one_s_p_0( X) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_p_0( OrdX, X, Ix). -ineq_one_s_p_0( X) :- % new variable, nothing depends on it - arith_eval( 0, Zero), - var_intern( t_u(Zero), X, 2'01). - -ineq_one_s_n_0( X) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_n_0( OrdX, X, Ix). -ineq_one_s_n_0( X) :- - arith_eval( 0, Zero), - var_intern( t_l(Zero), X, 2'10). - -ineq_one_s_p_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_p_i( OrdX, I, X, Ix). -ineq_one_s_p_i( X, I) :- - arith_eval( -I, Bound), - var_intern( t_u(Bound), X, 2'01). - -ineq_one_s_n_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_n_i( OrdX, I, X, Ix). -ineq_one_s_n_i( X, I) :- - var_intern( t_l(I), X, 2'10). - -ineq_one_old_s_p_0( [], _, Ix) :- - arith_eval( Ix < 0). -ineq_one_old_s_p_0( [Y*Ky|Tail], X, Ix) :- - ( Tail = [], - arith_eval( -Ix/Ky, Bound), - update_indep( strict, Y, Ky, Bound) - ; Tail = [_|_], - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udus( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_s_n_0( [], _, Ix) :- - arith_eval( Ix > 0). -ineq_one_old_s_n_0( [Y*Ky|Tail], X, Ix) :- - ( Tail = [], - arith_eval( -Ky, Coeff), - arith_eval( Ix/Coeff, Bound), - update_indep( strict, Y, Coeff, Bound) - ; Tail = [_|_], - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udls( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_s_p_i( [], I, _, Ix) :- - arith_eval( Ix+I < 0). -ineq_one_old_s_p_i( [Y*Ky|Tail], I, X, Ix) :- - ( Tail = [], - arith_eval( -(Ix+I)/Ky, Bound), - update_indep( strict, Y, Ky, Bound) - ; Tail = [_|_], - arith_eval( -I, Bound), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udus( Type, X, Lin, Bound, Old) - ). - -ineq_one_old_s_n_i( [], I, _, Ix) :- - arith_eval( -Ix+I < 0). -ineq_one_old_s_n_i( [Y*Ky|Tail], I, X, Ix) :- - ( Tail = [], - arith_eval( -Ky, Coeff), - arith_eval( (Ix-I)/Coeff, Bound), - update_indep( strict, Y, Coeff, Bound) - ; Tail = [_|_], - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udls( Type, X, Lin, I, Old) - ). - -% -------------------------- nonstrict -------------------------- - -ineq_one_n_p_0( X) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_p_0( OrdX, X, Ix). -ineq_one_n_p_0( X) :- % new variable, nothing depends on it - arith_eval( 0, Zero), - var_intern( t_u(Zero), X, 2'00). - -ineq_one_n_n_0( X) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_n_0( OrdX, X, Ix). -ineq_one_n_n_0( X) :- - arith_eval( 0, Zero), - var_intern( t_l(Zero), X, 2'00). - -ineq_one_n_p_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_p_i( OrdX, I, X, Ix). -ineq_one_n_p_i( X, I) :- - arith_eval( -I, Bound), - var_intern( t_u(Bound), X, 2'00). - -ineq_one_n_n_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_n_i( OrdX, I, X, Ix). -ineq_one_n_n_i( X, I) :- - var_intern( t_l(I), X, 2'00). - -ineq_one_old_n_p_0( [], _, Ix) :- - arith_eval( Ix =< 0). -ineq_one_old_n_p_0( [Y*Ky|Tail], X, Ix) :- - ( Tail = [], - arith_eval( -Ix/Ky, Bound), - update_indep( nonstrict, Y, Ky, Bound) - ; Tail = [_|_], - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udu( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_n_n_0( [], _, Ix) :- - arith_eval( Ix >= 0). -ineq_one_old_n_n_0( [Y*Ky|Tail], X, Ix) :- - ( Tail = [], - arith_eval( -Ky, Coeff), - arith_eval( Ix/Coeff, Bound), - update_indep( nonstrict, Y, Coeff, Bound) - ; Tail = [_|_], - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udl( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_n_p_i( [], I, _, Ix) :- - arith_eval( Ix+I =< 0). -ineq_one_old_n_p_i( [Y*Ky|Tail], I, X, Ix) :- - ( Tail = [], - arith_eval( -(Ix+I)/Ky, Bound), - update_indep( nonstrict, Y, Ky, Bound) - ; Tail = [_|_], - arith_eval( -I, Bound), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udu( Type, X, Lin, Bound, Old) - ). - -ineq_one_old_n_n_i( [], I, _, Ix) :- - arith_eval( -Ix+I =< 0). -ineq_one_old_n_n_i( [Y*Ky|Tail], I, X, Ix) :- - ( Tail = [], - arith_eval( -Ky, Coeff), - arith_eval( (Ix-I)/Coeff, Bound), - update_indep( nonstrict, Y, Coeff, Bound) - ; Tail = [_|_], - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udl( Type, X, Lin, I, Old) - ). - -% --------------------------------------------------------------- - - -ineq_more( [], I, _, Strictness) :- ineq_ground( Strictness, I). -ineq_more( [X*K|Tail], Id, Lind, Strictness) :- - ( Tail = [], % one var: update bound instead of slack introduction - get_or_add_class( X, _), - arith_eval( -Id/K, Bound), - update_indep( Strictness, X, K, Bound) - ; Tail = [_|_], - ineq_more( Strictness, Lind) - ). - -ineq_more( strict, Lind) :- - ( unconstrained( Lind, U,K, Rest) -> % never fails, no implied value - arith_eval( 0, Z), - arith_eval( 1, One), - var_intern( t_l(Z), S, 2'10), - arith_eval( -1/K, Ki), - add_linear_ff( Rest, Ki, [Z,Z,S*One], Ki, LinU), - decompose( LinU, Hu, _, _), - get_or_add_class( U, Class), - same_class( Hu, Class), - backsubst( U, LinU) - ; - arith_eval( 0, Z), - var_with_def_intern( t_u(Z), S, Lind, 2'01), - basis_add( S, _), - determine_active_dec( Lind), - reconsider( S) - ). -ineq_more( nonstrict, Lind) :- - ( unconstrained( Lind, U,K, Rest) -> % never fails, no implied value - arith_eval( 0, Z), - arith_eval( 1, One), - var_intern( t_l(Z), S, 2'00), - arith_eval( -1/K, Ki), - add_linear_ff( Rest, Ki, [Z,Z,S*One], Ki, LinU), - decompose( LinU, Hu, _, _), - get_or_add_class( U, Class), - same_class( Hu, Class), - backsubst( U, LinU) - ; - arith_eval( 0, Z), - var_with_def_intern( t_u(Z), S, Lind, 2'00), - basis_add( S, _), - determine_active_dec( Lind), - reconsider( S) - ). - -update_indep( strict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - uils( Type, X, Lin, Bound, Old) - ; - uius( Type, X, Lin, Bound, Old) - ). -update_indep( nonstrict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - uil( Type, X, Lin, Bound, Old) - ; - uiu( Type, X, Lin, Bound, Old) - ). - - -% --------------------------------------------------------------------------------------- - -% -% Update a bound on a var xi -% -% a) independent variable -% -% a1) update inactive bound: done -% -% a2) update active bound: -% Determine [lu]b including most constraining row R -% If we are within: done -% else pivot(R,xi) and introduce bound via (b) -% -% a3) introduce a bound on an unconstrained var: -% All vars that depend on xi are unconstrained (invariant) -> -% the bound cannot invalidate any Lhs -% -% b) dependent variable -% -% repair upper or lower (maybe just swap with an unconstrained var from Rhs) -% - -% -% Sign = 1,0,-1 means inside,at,outside -% - -udl( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'00)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( 0, Z), - arith_eval( -1, Mone), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_inc( Lin), - reconsider( X) - ). -udl( t_l(L), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). -udl( t_u(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - ( - put_atts( X, type(t_lu(Bound,U))), - reconsider_lower( X, Lin, Bound) - )). -udl( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )) - )). - -udls( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'10)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_inc( Lin), - reconsider( X) - ). -udls( t_l(L), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). -udls( t_u(U), X, Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound). -udls( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). - - -udu( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'00)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_dec( Lin), - reconsider( X) - ). -udu( t_u(U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). -udu( t_l(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - ( - put_atts( X, type(t_lu(L,Bound))), - reconsider_upper( X, Lin, Bound) - )). -udu( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )) - )). - -udus( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'01)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_dec( Lin), - reconsider( X) - ). -udus( t_u(U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). -udus( t_l(L), X, Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound). -udus( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). - -uiu( t_none, X, _Lin, Bound, _) :- - put_atts( X, [type(t_u(Bound)),strictness(2'00)]). -uiu( t_u(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]) - )). -uiu( t_l(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lu(L,Bound)))). -uiu( t_L(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_Lu(L,Bound)))). -uiu( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]) - )) - )). -uiu( t_Lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]) - )) - )). -% -% update active: -% -uiu( t_U(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_u(Bound)), - reconsider( X) - ; - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). -uiu( t_lU(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_lu(L,Bound)), - reconsider( X) - ; - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )) - )). - - -uius( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'01)]). -uius( t_u(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]) - )). -uius( t_l(L), X, _Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]). -uius( t_L(L), X, _Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]). -uius( t_lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]) - )). -uius( t_Lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]) - )). -% -% update active: -% -uius( t_U(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_u(Bound)), - reconsider( X) - ; - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). -uius( t_lU(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_lu(L,Bound)), - reconsider( X) - ; - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). - - -uil( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'00)]). -uil( t_l(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]) - )). -uil( t_u(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lu(Bound,U)))). -uil( t_U(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lU(Bound,U)))). -uil( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]) - )) - )). -uil( t_lU(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]) - )) - )). -% -% update active bound: % { a>=100,d=<5000,c>=10,-2*a+d-c=10,a>=2490 }. -% -uil( t_L(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_l(Bound)), - reconsider( X) - ; % - % max(X) >= Ub, no implied value missed - % - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ) - )). -uil( t_Lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_lu(Bound,U)), - reconsider( X) - ; - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ) - )))). - - -uils( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'10)]). -uils( t_l(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]) - )). -uils( t_u(U), X, _Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]). -uils( t_U(U), X, _Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]). -uils( t_lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]) - )). -uils( t_lU(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]) - )). -% -% update active bound: -% -uils( t_L(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_l(Bound)), - reconsider( X) - ; % - % max(X) >= Ub, no implied value missed - % - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ))). -uils( t_Lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_lu(Bound,U)), - reconsider( X) - ; - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ))). - -reconsider_upper( X, Lin, U) :- - decompose( Lin, H, R, I), - arith_eval( R+I >= U), - !, - dec_step( H, Status), - rcbl_status( Status, X, [], Binds,[], u(U)), - export_binding( Binds). -reconsider_upper( _, _, _). - -reconsider_lower( X, Lin, L) :- - decompose( Lin, H, R, I), - arith_eval( R+I =< L), - !, - inc_step( H, Status), - rcbl_status( Status, X, [], Binds,[], l(L)), - export_binding( Binds). -reconsider_lower( _, _, _). - -% -% lin is dereferenced -% -solve_bound( Lin, Bound) :- - arith_eval( Bound =:= 0), - !, - solve( Lin). -solve_bound( Lin, Bound) :- - arith_eval( -Bound, Nb), - normalize_scalar( Nb, Nbs), - add_linear_11( Nbs, Lin, Eq), - solve( Eq). diff --git a/CLPQR/clpqr/ineq.yap b/CLPQR/clpqr/ineq.yap deleted file mode 100644 index e4812aa77..000000000 --- a/CLPQR/clpqr/ineq.yap +++ /dev/null @@ -1,993 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: ineq.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Lin (=)< 0 -% -ineq( [], I, _, Strictness) :- ineq_ground( Strictness, I). -ineq( [v(K,[X^1])|Tail], I, Lin, Strictness) :- - ineq_cases( Tail, I, Lin, Strictness, X, K). - -ineq_cases( [], I, _, Strictness, X, K) :- - ineq_one( Strictness, X, K, I). -ineq_cases( [_|_], _, Lin, Strictness, _, _) :- - deref( Lin, Lind), % Id+Hd =< 0 - decompose( Lind, Hom, _, Inhom), - ineq_more( Hom, Inhom, Lind, Strictness). - -ineq_ground( strict, I) :- arith_eval( I < 0). -ineq_ground( nonstrict, I) :- arith_eval( I =< 0). - -% -% Special cases: k={+-}1,i=0 -% -ineq_one( strict, X, K, I) :- - ( arith_eval(K>0) -> - ( arith_eval(I=:=0) -> - ineq_one_s_p_0( X) - ; - arith_eval( I/K, Inhom), - ineq_one_s_p_i( X, Inhom) - ) - ; - ( arith_eval(I=:=0) -> - ineq_one_s_n_0( X) - ; - arith_eval( -I/K, Inhom), - ineq_one_s_n_i( X, Inhom) - ) - ). -ineq_one( nonstrict, X, K, I) :- - ( arith_eval(K>0) -> - ( arith_eval(I=:=0) -> - ineq_one_n_p_0( X) - ; - arith_eval( I/K, Inhom), - ineq_one_n_p_i( X, Inhom) - ) - ; - ( arith_eval(I=:=0) -> - ineq_one_n_n_0( X) - ; - arith_eval( -I/K, Inhom), - ineq_one_n_n_i( X, Inhom) - ) - ). - -/* -ineq_one( Strictness, X, K, I) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old( OrdX, K, I, Strictness, X, Ix). -ineq_one( Strictness, X, K, I) :- % new variable, nothing depends on it - arith_eval( -I/K, Bound), - ineq_one_new( Strictness, X, K, Bound). - -ineq_one_new( strict, X, K, Bound) :- - arith_eval( 1, One), - ( arith_eval( K < 0) -> - var_intern( t_l(Bound), X, 2'10) - ; - var_intern( t_u(Bound), X, 2'01) - ). -ineq_one_new( nonstrict, X, K, Bound) :- - arith_eval( 1, One), - ( arith_eval( K < 0) -> - var_intern( t_l(Bound), X, 2'00) - ; - var_intern( t_u(Bound), X, 2'00) - ). - - -ineq_one_old( [], K, I, Strictness, _X, Ix) :- - arith_eval( K*Ix+I, Inhom), - ineq_ground( Strictness, Inhom). -% -% here we would have the choice to bound X or Y -% -ineq_one_old( [Y*Ky|Tail], K, I, Strictness, X, Ix) :- - ( Tail = [], - arith_eval( K*Ky, Coeff), - arith_eval( -(K*Ix+I)/Coeff, Bound), - update_indep( Strictness, Y, Coeff, Bound) - ; Tail = [_|_], - arith_eval( -I/K, Bound), - update_dep( Strictness, X, K, Bound) - ). - -update_dep( strict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - udls( Type, X, Lin, Bound, Old) - ; - udus( Type, X, Lin, Bound, Old) - ). -update_dep( nonstrict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - udl( Type, X, Lin, Bound, Old) - ; - udu( Type, X, Lin, Bound, Old) - ). -*/ - -% --------------------------- strict ---------------------------- - -ineq_one_s_p_0( X) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_p_0( OrdX, X, Ix). -ineq_one_s_p_0( X) :- % new variable, nothing depends on it - arith_eval( 0, Zero), - var_intern( t_u(Zero), X, 2'01). - -ineq_one_s_n_0( X) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_n_0( OrdX, X, Ix). -ineq_one_s_n_0( X) :- - arith_eval( 0, Zero), - var_intern( t_l(Zero), X, 2'10). - -ineq_one_s_p_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_p_i( OrdX, I, X, Ix). -ineq_one_s_p_i( X, I) :- - arith_eval( -I, Bound), - var_intern( t_u(Bound), X, 2'01). - -ineq_one_s_n_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_s_n_i( OrdX, I, X, Ix). -ineq_one_s_n_i( X, I) :- - var_intern( t_l(I), X, 2'10). - -ineq_one_old_s_p_0( [], _, Ix) :- - arith_eval( Ix < 0). -ineq_one_old_s_p_0( [Y*Ky|Tail], X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ix/Ky, Bound), - update_indep( strict, Y, Ky, Bound) - ; Tail = [_|_] -> - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udus( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_s_n_0( [], _, Ix) :- - arith_eval( Ix > 0). -ineq_one_old_s_n_0( [Y*Ky|Tail], X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ky, Coeff), - arith_eval( Ix/Coeff, Bound), - update_indep( strict, Y, Coeff, Bound) - ; Tail = [_|_] -> - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udls( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_s_p_i( [], I, _, Ix) :- - arith_eval( Ix+I < 0). -ineq_one_old_s_p_i( [Y*Ky|Tail], I, X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -(Ix+I)/Ky, Bound), - update_indep( strict, Y, Ky, Bound) - ; Tail = [_|_] -> - arith_eval( -I, Bound), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udus( Type, X, Lin, Bound, Old) - ). - -ineq_one_old_s_n_i( [], I, _, Ix) :- - arith_eval( -Ix+I < 0). -ineq_one_old_s_n_i( [Y*Ky|Tail], I, X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ky, Coeff), - arith_eval( (Ix-I)/Coeff, Bound), - update_indep( strict, Y, Coeff, Bound) - ; Tail = [_|_] -> - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udls( Type, X, Lin, I, Old) - ). - -% -------------------------- nonstrict -------------------------- - -ineq_one_n_p_0( X) :- - get_atts( X, lin(LinX)), - !, % old variable, this is deref - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_p_0( OrdX, X, Ix). -ineq_one_n_p_0( X) :- % new variable, nothing depends on it - arith_eval( 0, Zero), - var_intern( t_u(Zero), X, 2'00). - -ineq_one_n_n_0( X) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_n_0( OrdX, X, Ix). -ineq_one_n_n_0( X) :- - arith_eval( 0, Zero), - var_intern( t_l(Zero), X, 2'00). - -ineq_one_n_p_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_p_i( OrdX, I, X, Ix). -ineq_one_n_p_i( X, I) :- - arith_eval( -I, Bound), - var_intern( t_u(Bound), X, 2'00). - -ineq_one_n_n_i( X, I) :- - get_atts( X, lin(LinX)), - !, - decompose( LinX, OrdX, _, Ix), - ineq_one_old_n_n_i( OrdX, I, X, Ix). -ineq_one_n_n_i( X, I) :- - var_intern( t_l(I), X, 2'00). - -ineq_one_old_n_p_0( [], _, Ix) :- - arith_eval( Ix =< 0). -ineq_one_old_n_p_0( [Y*Ky|Tail], X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ix/Ky, Bound), - update_indep( nonstrict, Y, Ky, Bound) - ; Tail = [_|_] -> - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udu( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_n_n_0( [], _, Ix) :- - arith_eval( Ix >= 0). -ineq_one_old_n_n_0( [Y*Ky|Tail], X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ky, Coeff), - arith_eval( Ix/Coeff, Bound), - update_indep( nonstrict, Y, Coeff, Bound) - ; Tail = [_|_] -> - arith_eval( 0, Zero), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udl( Type, X, Lin, Zero, Old) - ). - -ineq_one_old_n_p_i( [], I, _, Ix) :- - arith_eval( Ix+I =< 0). -ineq_one_old_n_p_i( [Y*Ky|Tail], I, X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -(Ix+I)/Ky, Bound), - update_indep( nonstrict, Y, Ky, Bound) - ; Tail = [_|_] -> - arith_eval( -I, Bound), - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udu( Type, X, Lin, Bound, Old) - ). - -ineq_one_old_n_n_i( [], I, _, Ix) :- - arith_eval( -Ix+I =< 0). -ineq_one_old_n_n_i( [Y*Ky|Tail], I, X, Ix) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> - arith_eval( -Ky, Coeff), - arith_eval( (Ix-I)/Coeff, Bound), - update_indep( nonstrict, Y, Coeff, Bound) - ; Tail = [_|_] -> - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - udl( Type, X, Lin, I, Old) - ). - -% --------------------------------------------------------------- - - -ineq_more( [], I, _, Strictness) :- ineq_ground( Strictness, I). -ineq_more( [X*K|Tail], Id, Lind, Strictness) :- - %vsc: added -> (01/06/06) - ( Tail = [] -> % one var: update bound instead of slack introduction - get_or_add_class( X, _), - arith_eval( -Id/K, Bound), - update_indep( Strictness, X, K, Bound) - ; Tail = [_|_] -> - ineq_more( Strictness, Lind) - ). - -ineq_more( strict, Lind) :- - ( unconstrained( Lind, U,K, Rest) -> % never fails, no implied value - arith_eval( 0, Z), - arith_eval( 1, One), - var_intern( t_l(Z), S, 2'10), - arith_eval( -1/K, Ki), - add_linear_ff( Rest, Ki, [Z,Z,S*One], Ki, LinU), - decompose( LinU, Hu, _, _), - get_or_add_class( U, Class), - same_class( Hu, Class), - backsubst( U, LinU) - ; - arith_eval( 0, Z), - var_with_def_intern( t_u(Z), S, Lind, 2'01), - basis_add( S, _), - determine_active_dec( Lind), - reconsider( S) - ). -ineq_more( nonstrict, Lind) :- - ( unconstrained( Lind, U,K, Rest) -> % never fails, no implied value - arith_eval( 0, Z), - arith_eval( 1, One), - var_intern( t_l(Z), S, 2'00), - arith_eval( -1/K, Ki), - add_linear_ff( Rest, Ki, [Z,Z,S*One], Ki, LinU), - decompose( LinU, Hu, _, _), - get_or_add_class( U, Class), - same_class( Hu, Class), - backsubst( U, LinU) - ; - arith_eval( 0, Z), - var_with_def_intern( t_u(Z), S, Lind, 2'00), - basis_add( S, _), - determine_active_dec( Lind), - reconsider( S) - ). - -update_indep( strict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - uils( Type, X, Lin, Bound, Old) - ; - uius( Type, X, Lin, Bound, Old) - ). -update_indep( nonstrict, X, K, Bound) :- - get_atts( X, [lin(Lin),type(Type),strictness(Old)]), - ( arith_eval( K < 0) -> - uil( Type, X, Lin, Bound, Old) - ; - uiu( Type, X, Lin, Bound, Old) - ). - - -% --------------------------------------------------------------------------------------- - -% -% Update a bound on a var xi -% -% a) independent variable -% -% a1) update inactive bound: done -% -% a2) update active bound: -% Determine [lu]b including most constraining row R -% If we are within: done -% else pivot(R,xi) and introduce bound via (b) -% -% a3) introduce a bound on an unconstrained var: -% All vars that depend on xi are unconstrained (invariant) -> -% the bound cannot invalidate any Lhs -% -% b) dependent variable -% -% repair upper or lower (maybe just swap with an unconstrained var from Rhs) -% - -% -% Sign = 1,0,-1 means inside,at,outside -% - -udl( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'00)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( 0, Z), - arith_eval( -1, Mone), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_inc( Lin), - reconsider( X) - ). -udl( t_l(L), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). -udl( t_u(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - ( - put_atts( X, type(t_lu(Bound,U))), - reconsider_lower( X, Lin, Bound) - )). -udl( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )) - )). - -udls( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'10)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_inc( Lin), - reconsider( X) - ). -udls( t_l(L), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). -udls( t_u(U), X, Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound). -udls( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]), - reconsider_lower( X, Lin, Bound) - )). - - -udu( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'00)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_dec( Lin), - reconsider( X) - ). -udu( t_u(U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). -udu( t_l(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - ( - put_atts( X, type(t_lu(L,Bound))), - reconsider_upper( X, Lin, Bound) - )). -udu( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )) - )). - -udus( t_none, X, Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'01)]), - ( unconstrained( Lin, Uc,Kuc, Rest) -> - arith_eval( -1/Kuc, Ki), - arith_eval( -1, Mone), - arith_eval( 0, Z), - add_linear_ff( Rest, Ki, [Z,Z,X*Mone], Ki, LinU), - backsubst( Uc, LinU) - ; - basis_add( X, _), - determine_active_dec( Lin), - reconsider( X) - ). -udus( t_u(U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). -udus( t_l(L), X, Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound). -udus( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]), - reconsider_upper( X, Lin, Bound) - )). - -uiu( t_none, X, _Lin, Bound, _) :- - put_atts( X, [type(t_u(Bound)),strictness(2'00)]). -uiu( t_u(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]) - )). -uiu( t_l(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lu(L,Bound)))). -uiu( t_L(L), X, Lin, Bound, _Sold) :- - case_signum( Bound-L, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_Lu(L,Bound)))). -uiu( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]) - )) - )). -uiu( t_Lu(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]) - )) - )). -% -% update active: -% -uiu( t_U(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - Strict is Sold /\ 2'10, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_u(Bound)), - reconsider( X) - ; - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). -uiu( t_lU(L,U), X, Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - true, - ( - case_signum( Bound-L, - fail, - ( - Sold /\ 2'10 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'10, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_lu(L,Bound)), - reconsider( X) - ; - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )) - )). - - -uius( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_u(Bound)),strictness(2'01)]). -uius( t_u(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - put_atts( X, [type(t_u(Bound)),strictness(Strict)]) - )). -uius( t_l(L), X, _Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]). -uius( t_L(L), X, _Lin, Bound, Sold) :- - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]). -uius( t_lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_lu(L,Bound)),strictness(Strict)]) - )). -uius( t_Lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - put_atts( X, [type(t_Lu(L,Bound)),strictness(Strict)]) - )). -% -% update active: -% -uius( t_U(U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'01, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_u(Bound)), - reconsider( X) - ; - put_atts( X, [type(t_U(Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). -uius( t_lU(L,U), X, _Lin, Bound, Sold) :- - case_signum( U-Bound, - true, - ( - Strict is Sold \/ 2'01, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( Bound>L), - Strict is Sold \/ 2'01, - ( lb( X, Vlb-Vb-Lb), - arith_eval( Bound =< Lb+U) -> - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - pivot_a( Vlb, X, Vb, t_lu(L,Bound)), - reconsider( X) - ; - put_atts( X, [type(t_lU(L,Bound)),strictness(Strict)]), - arith_eval( Bound-U, Delta), - backsubst_delta( X, Delta) - ) - )). - - -uil( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'00)]). -uil( t_l(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]) - )). -uil( t_u(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lu(Bound,U)))). -uil( t_U(U), X, Lin, Bound, _Sold) :- - case_signum( U-Bound, - fail, - solve_bound( Lin, Bound), - put_atts( X, type(t_lU(Bound,U)))). -uil( t_lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]) - )) - )). -uil( t_lU(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]) - )) - )). -% -% update active bound: % { a>=100,d=<5000,c>=10,-2*a+d-c=10,a>=2490 }. -% -uil( t_L(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - Strict is Sold /\ 2'01, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_l(Bound)), - reconsider( X) - ; % - % max(X) >= Ub, no implied value missed - % - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ) - )). -uil( t_Lu(L,U), X, Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - true, - ( - case_signum( U-Bound, - fail, - ( - Sold /\ 2'01 =:= 0, - solve_bound( Lin, Bound) - ), - ( - Strict is Sold /\ 2'01, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_lu(Bound,U)), - reconsider( X) - ; - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ) - )))). - - -uils( t_none, X, _Lin, Bound, _Sold) :- - put_atts( X, [type(t_l(Bound)),strictness(2'10)]). -uils( t_l(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - put_atts( X, [type(t_l(Bound)),strictness(Strict)]) - )). -uils( t_u(U), X, _Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]). -uils( t_U(U), X, _Lin, Bound, Sold) :- - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]). -uils( t_lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lu(Bound,U)),strictness(Strict)]) - )). -uils( t_lU(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - put_atts( X, [type(t_lU(Bound,U)),strictness(Strict)]) - )). -% -% update active bound: -% -uils( t_L(L), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - Strict is Sold \/ 2'10, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_l(Bound)), - reconsider( X) - ; % - % max(X) >= Ub, no implied value missed - % - put_atts( X, [type(t_L(Bound)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ))). -uils( t_Lu(L,U), X, _Lin, Bound, Sold) :- - case_signum( Bound-L, - true, - ( - Strict is Sold \/ 2'10, - put_atts( X, strictness(Strict)) - ), - ( - arith_eval( U>Bound), - Strict is Sold \/ 2'10, - ( ub( X, Vub-Vb-Ub), - arith_eval( Bound >= Ub+L) -> - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - pivot_a( Vub, X, Vb, t_lu(Bound,U)), - reconsider( X) - ; - put_atts( X, [type(t_Lu(Bound,U)),strictness(Strict)]), - arith_eval( Bound-L, Delta), - backsubst_delta( X, Delta) - ))). - -reconsider_upper( X, Lin, U) :- - decompose( Lin, H, R, I), - arith_eval( R+I >= U), - !, - dec_step( H, Status), - rcbl_status( Status, X, [], Binds,[], u(U)), - export_binding( Binds). -reconsider_upper( _, _, _). - -reconsider_lower( X, Lin, L) :- - decompose( Lin, H, R, I), - arith_eval( R+I =< L), - !, - inc_step( H, Status), - rcbl_status( Status, X, [], Binds,[], l(L)), - export_binding( Binds). -reconsider_lower( _, _, _). - -% -% lin is dereferenced -% -solve_bound( Lin, Bound) :- - arith_eval( Bound =:= 0), - !, - solve( Lin). -solve_bound( Lin, Bound) :- - arith_eval( -Bound, Nb), - normalize_scalar( Nb, Nbs), - add_linear_11( Nbs, Lin, Eq), - solve( Eq). diff --git a/CLPQR/clpqr/itf3.pl b/CLPQR/clpqr/itf3.pl deleted file mode 100644 index 823e58d50..000000000 --- a/CLPQR/clpqr/itf3.pl +++ /dev/null @@ -1,273 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: itf3.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% interface to attribute encoding and hooks -% - -:- use_module( library(atts)). - -:- attribute class/1, order/1, lin/1, forward/1, - type/1, strictness/1, nonzero/0, - target/0, keep_indep/0, keep/0. % project.pl - -/* Moved here from store.pl to break cyclic dependencies. --Mats C. */ -% -% critical impact on the backsubstitution effort -% AND precision in clp(r) -% -% nf_ordering( A, B, Rel) :- -% get_atts( A, order( Oa)), -% get_atts( B, order( Ob)), -% compare( Rel, Oa, Ob). - -:- multifile - user:goal_expansion/3. - -:- dynamic - user:goal_expansion/3. -% -user:goal_expansion( nf_ordering(A,B,Rel), Module, Exp) :- - clpqr( Module), - Exp = ( - get_atts( A, order(Oa)), - get_atts( B, order(Ob)), - compare( Rel, Oa, Ob) - ). - -user:goal_expansion( decompose(Lin,H,R,I), Module, Lin=[I,R|H]) :- - clpqr( Module). - -clpqr( clpq). -clpqr( clpr). -/* End of code from store.pl */ - -% -% Parametrize the answer presentation mechanism -% (toplevel,compiler/debugger ...) -% -:- dynamic presentation_context/1. - -presentation_context( Old, New) :- - clause( presentation_context(Current), _), - !, - Current = Old, - retractall( presentation_context(_)), - assert( presentation_context( New)). -presentation_context( toplevel, New) :- % default - assert( presentation_context( New)). - -% -% attribute_goal( V, V:Atts) :- get_atts( V, Atts). -% -attribute_goal( V, Goal) :- - presentation_context( Cont, Cont), - dump_linear( V, Cont, Goals, Gtail), - dump_nonzero( V, Cont, Gtail, []), - l2wrapped( Goals, Goal). - -l2wrapped( [], true). -l2wrapped( [X|Xs], Conj) :- - ( Xs = [], wrap( X, Conj) - ; Xs = [_|_], wrap( X, Xw), - Conj = (Xw,Xc), - l2wrapped( Xs, Xc) - ). - -% -% Tests should be pulled out of the loop ... -% -wrap( C, W) :- - prolog_flag(typein_module, Module), - this_linear_solver( Solver), - ( Module == Solver -> - W = {C} - ; predicate_property( Module:{_}, imported_from(Solver)) -> - W = {C} - ; - W = Solver:{C} - ). - -dump_linear( V, Context) --> - { - get_atts( V, [lin(Lin),type(Type)]), - !, - decompose( Lin, H, _, I) - }, - % - % This happens if not all target variables can be made independend - % Example: examples/option.pl: - % | ?- go2(S,W). - % - % W = 21/4, - % S>=0, - % S<50 ? ; - % - % W>5, - % S=221/4-W, this line would be missing !!! - % W=<21/4 - % - ( { Type=t_none ; get_atts( V, -target) } -> [] ; dump_v( Context, t_none, V, I, H) ), - % - ( {Type=t_none, get_atts( V, -target) } -> % nonzero produces such - [] - ; - dump_v( Context, Type, V, I, H) - ). -dump_linear( _, _) --> []. - -dump_v( toplevel, Type, V, I, H) --> dump_var( Type, V, I, H). -dump_v( compiler, Type, V, I, H) --> compiler_dump_var( Type, V, I, H). - -dump_nonzero( V, Cont) --> - { - get_atts( V, [nonzero,lin(Lin)]), - !, - decompose( Lin, H, _, I) - }, - dump_nz( Cont, V, H, I). -dump_nonzero( _, _) --> []. - -dump_nz( toplevel, V, H, I) --> dump_nz( V, H, I). -dump_nz( compiler, V, H, I) --> compiler_dump_nz( V, H, I). - -numbers_only( Y, _) :- var(Y), !. -numbers_only( Y, _) :- arith_normalize( Y, Y), !. -numbers_only( Y, X) :- - this_linear_solver( Solver), - ( Solver==clpr -> - What = 'a real number' - ; Solver==clpq -> - What = 'a rational number' - ), - raise_exception( type_error(X=Y,2,What,Y)). - -verify_attributes( X, _, []) :- - get_atts(X, [-class(_),-order(_),-lin(_),-forward(_),-type(_),-strictness(_), - -nonzero]), - !. -verify_attributes( X, Y, []) :- - get_atts( X, forward(F)), - !, - fwd_deref( F, Y). -verify_attributes( X, Y, Later) :- - numbers_only( Y, X), - put_atts( X, forward(Y)), - verify_nonzero( X, Y), - verify_type( X, Y, Later, []), - verify_lin( X, Y). - -fwd_deref( X, Y) :- nonvar(X), X=Y. -fwd_deref( X, Y) :- var(X), - ( get_atts( X, forward(F)) -> - fwd_deref( F, Y) - ; - X = Y - ). - -verify_nonzero( X, Y) :- - get_atts( X, nonzero), - !, - ( var(Y) -> - put_atts( Y, nonzero) - ; - arith_eval( Y =\= 0) - ). -verify_nonzero( _, _). - -verify_type( X, Y) --> - { - get_atts( X, [type(Type),strictness(Strict)]) - }, - !, - verify_type( Y, Type, Strict). -verify_type( _, _) --> []. - -verify_type( Y, TypeX, StrictX) --> {var(Y)}, !, - verify_type_var( TypeX, Y, StrictX). -verify_type( Y, TypeX, StrictX) --> - { - verify_type_nonvar( TypeX, Y, StrictX) - }. - - verify_type_nonvar( t_none, _, _). - verify_type_nonvar( t_l(L), Value, S) :- lb( S, L, Value). - verify_type_nonvar( t_u(U), Value, S) :- ub( S, U, Value). - verify_type_nonvar( t_lu(L,U), Value, S) :- lb( S, L, Value), ub( S, U, Value). - verify_type_nonvar( t_L(L), Value, S) :- lb( S, L, Value). - verify_type_nonvar( t_U(U), Value, S) :- ub( S, U, Value). - verify_type_nonvar( t_Lu(L,U), Value, S) :- lb( S, L, Value), ub( S, U, Value). - verify_type_nonvar( t_lU(L,U), Value, S) :- lb( S, L, Value), ub( S, U, Value). - - lb( S, L, V) :- S /\ 2'10 =:= 0, !, arith_eval( L =< V). - lb( _, L, V) :- arith_eval( L < V). - - ub( S, U, V) :- S /\ 2'01 =:= 0, !, arith_eval( V =< U). - ub( _, U, V) :- arith_eval( V < U). - - -% -% Running some goals after X=Y simplifies the coding. It should be possible -% to run the goals here and taking care not to put_atts/2 on X ... -% - verify_type_var( t_none, _, _) --> []. - verify_type_var( t_l(L), Y, S) --> llb( S, L, Y). - verify_type_var( t_u(U), Y, S) --> lub( S, U, Y). - verify_type_var( t_lu(L,U), Y, S) --> llb( S, L, Y), lub( S, U, Y). - verify_type_var( t_L(L), Y, S) --> llb( S, L, Y). - verify_type_var( t_U(U), Y, S) --> lub( S, U, Y). - verify_type_var( t_Lu(L,U), Y, S) --> llb( S, L, Y), lub( S, U, Y). - verify_type_var( t_lU(L,U), Y, S) --> llb( S, L, Y), lub( S, U, Y). - - llb( S, L, V) --> {S /\ 2'10 =:= 0}, !, [ {L =< V} ]. - llb( _, L, V) --> [ {L < V} ]. - - lub( S, U, V) --> {S /\ 2'01 =:= 0}, !, [ {V =< U} ]. - lub( _, U, V) --> [ {V < U} ]. - - -% -% We used to drop X from the class/basis to avoid trouble with subsequent -% put_atts/2 on X. Now we could let these dead but harmless updates happen. -% In R however, exported bindings might conflict, e.g. 0 \== 0.0 -% -% If X is indep and we do _not_ solve for it, we are in deep shit -% because the ordering is violated. -% -verify_lin( X, Y) :- - get_atts( X, [class(Class),lin(LinX)]), - !, - ( indep( LinX, X) -> - detach_bounds( X), % if there were bounds, they are requeued already - class_drop( Class, X), - nf( X-Y, Lin), - deref( Lin, Lind), - ( nf_coeff_of( Lind, X, _) -> - solve_x( Lind, X) - ; - solve( Lind) - ) - ; - class_drop( Class, X), - nf( X-Y, Lin), - deref( Lin, Lind), - solve( Lind) - ). -verify_lin( _, _). - - - - - - - diff --git a/CLPQR/clpqr/monash.pl b/CLPQR/clpqr/monash.pl deleted file mode 100644 index 6eabb455d..000000000 --- a/CLPQR/clpqr/monash.pl +++ /dev/null @@ -1,27 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: monash.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Monash compatibility -% - -:- op( 700, xfx, <=). -:- op( 150, fx, #). - -:- use_module( printf). -:- use_module( expand). - -:- prolog_flag( unknown, _, fail). - -dump. % cheating -dump( L) :- ordering( L). diff --git a/CLPQR/clpqr/nf.pl b/CLPQR/clpqr/nf.pl deleted file mode 100644 index 156ccac64..000000000 --- a/CLPQR/clpqr/nf.pl +++ /dev/null @@ -1,834 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nf.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- use_module( library(terms), [term_variables/2]). -:- use_module( geler). - -% ------------------------------------------------------------------------- - -{ Rel } :- var( Rel), !, raise_exception(instantiation_error({Rel},1)). -{ R,Rs } :- !, {R}, {Rs}. -{ R;Rs } :- !, ({R} ; {Rs}). % for entailment checking -{ L < R } :- !, nf( L-R, Nf), submit_lt( Nf). -{ L > R } :- !, nf( R-L, Nf), submit_lt( Nf). -{ L =< R } :- !, nf( L-R, Nf), submit_le( Nf). -{ <=(L,R) } :- !, nf( L-R, Nf), submit_le( Nf). -{ L >= R } :- !, nf( R-L, Nf), submit_le( Nf). -{ L =\= R } :- !, nf( L-R, Nf), submit_ne( Nf). -{ L =:= R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ L = R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ Rel } :- raise_exception( type_error({Rel},1,'a constraint',Rel)). - -% -% s -> c = ~s v c = ~(s /\ ~c) -% where s is the store and c is the constraint for which -% we want to know whether it is entailed. -% -entailed( C) :- - negate( C, Cn), - \+ { Cn }. - -negate( Rel, _) :- var( Rel), !, raise_exception(instantiation_error(entailed(Rel),1)). -negate( (A,B), (Na;Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( (A;B), (Na,Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( A=B) :- !. -negate( A>B, A=B) :- !. -negate( A>=B, A A=0 - b4) nonlinear -> geler - c) Nf=[A,B|Rest] - c1) A=k - c11) B=X^+-1, Rest=[] -> B= - c12) invertible(A,B) - c13) linear(B|Rest) - c14) geler - c2) linear(Nf) - c3) nonlinear -> geler -*/ -submit_eq( []). % trivial success -submit_eq( [T|Ts]) :- - submit_eq( Ts, T). - -submit_eq( [], A) :- submit_eq_b( A). -submit_eq( [B|Bs], A) :- submit_eq_c( A, B, Bs). - -submit_eq_b( v(_,[])) :- !, fail. % b1: trivial failure -submit_eq_b( v(_,[X^P])) :- % b2,b3: n*x^p=0 -> x=0 - var( X), - P > 0, - !, - arith_eval( 0, Z), - export_binding( X, Z). -submit_eq_b( v(_,[NL^1])) :- % b2 - nonvar( NL), - arith_eval( 0, Z), - nl_invertible( NL, X, Z, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_b( Term) :- % b4 - term_variables( Term, Vs), - geler( Vs, resubmit_eq([Term])). - -submit_eq_c( v(I,[]), B, Rest) :- !, - submit_eq_c1( Rest, B, I). -submit_eq_c( A, B, Rest) :- % c2 - A=v(_,[X^1]), var(X), - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - Hom = [A,B|Rest], - % 'solve_='( Hom). - nf_length( Hom, 0, Len), - log_deref( Len, Hom, [], HomD), - solve( HomD). -submit_eq_c( A, B, Rest) :- % c3 - Norm = [A,B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -submit_eq_c1( [], v(K,[X^P]), I) :- % c11 - var( X), - ( P = 1, !, arith_eval( -I/K, Val), export_binding( X, Val) - ; P = -1, !, arith_eval( -K/I, Val), export_binding( X, Val) - ). -submit_eq_c1( [], v(K,[NL^P]), I) :- % c12 - nonvar( NL), - ( P = 1, arith_eval( -I/K, Y) - ; P = -1, arith_eval( -K/I, Y) - ), - nl_invertible( NL, X, Y, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_c1( Rest, B, I) :- % c13 - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - % 'solve_='( [v(I,[]),B|Rest]). - Hom = [B|Rest], - nf_length( Hom, 0, Len), - normalize_scalar( I, Nonvar), - log_deref( Len, Hom, [], HomD), - add_linear_11( Nonvar, HomD, LinD), - solve( LinD). -submit_eq_c1( Rest, B, I) :- % c14 - Norm = [v(I,[]),B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -% ----------------------------------------------------------------------- - -submit_lt( []) :- fail. % trivial failure -submit_lt( [A|As]) :- - submit_lt( As, A). - -submit_lt( [], v(K,P)) :- submit_lt_b( P, K). -submit_lt( [B|Bs], A) :- submit_lt_c( Bs, A, B). - -submit_lt_b( [], I) :- !, arith_eval( I<0). -submit_lt_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_s_p_0( X) - ; - ineq_one_s_n_0( X) - ). -submit_lt_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_lt([v(K,P)])). - -submit_lt_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( strict, Y, K, I). -submit_lt_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_lt(Norm)) - ). - -submit_le( []). % trivial success -submit_le( [A|As]) :- - submit_le( As, A). - -submit_le( [], v(K,P)) :- submit_le_b( P, K). -submit_le( [B|Bs], A) :- submit_le_c( Bs, A, B). - -submit_le_b( [], I) :- !, arith_eval( I=<0). -submit_le_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_n_p_0( X) - ; - ineq_one_n_n_0( X) - ). -submit_le_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_le([v(K,P)])). - -submit_le_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( nonstrict, Y, K, I). -submit_le_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_=<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_le(Norm)) - ). - -submit_ne( Norm1) :- - ( nf_constant( Norm1, K) -> - arith_eval( K=\=0) - ; linear( Norm1) -> - 'solve_=\='( Norm1) - ; - term_variables( Norm1, Vs), - geler( Vs, resubmit_ne(Norm1)) - ). - - -linear( []). -linear( v(_,Ps)) :- linear_ps( Ps). -linear( [A|As]) :- - linear( A), - linear( As). - -linear_ps( []). -linear_ps( [V^1]) :- var( V). % excludes sin(_), ... - -% -% Goal delays until Term gets linear. -% At this time, Var will be bound to the normalform of Term. -% -:- meta_predicate wait_linear( ?, ?, :). -% -wait_linear( Term, Var, Goal) :- - nf( Term, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% -% geler clients -% -resubmit_eq( N) :- - repair( N, Norm), - submit_eq( Norm). - -resubmit_lt( N) :- - repair( N, Norm), - submit_lt( Norm). - -resubmit_le( N) :- - repair( N, Norm), - submit_le( Norm). - -resubmit_ne( N) :- - repair( N, Norm), - submit_ne( Norm). - -wait_linear_retry( Nf0, Var, Goal) :- - repair( Nf0, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% ----------------------------------------------------------------------- - -/* -invertible( [v(Mone,[]),v(One,[X^Px,Y^Py])], Norm) :- - Px+Py =:= 0, - abs(Px) mod 2 =:= 1, % odd powers only ... - arith_eval( 1, One), - arith_eval( -1, Mone), - !, - ( Px < 0 -> - {X=\=0} - ; - {Y=\=0} - ), - nf( X-Y, Norm). % x=y -*/ - -nl_invertible( sin(X), X, Y, Res) :- arith_eval( asin(Y), Res). -nl_invertible( cos(X), X, Y, Res) :- arith_eval( acos(Y), Res). -nl_invertible( tan(X), X, Y, Res) :- arith_eval( atan(Y), Res). -nl_invertible( exp(B,C), X, A, Res) :- - ( nf_constant( B, Kb) -> - arith_eval(A>0), - arith_eval(Kb>0), - arith_eval(Kb=\=1), - X = C, - arith_eval( log(A)/log(Kb), Res) - ; nf_constant( C, Kc), - \+ (arith_eval(A=:=0),arith_eval(Kc=<0)), - X = B, - arith_eval( exp(A,1/Kc), Res) - ). - -% ----------------------------------------------------------------------- - -nf( X, Norm) :- var(X), !, - Norm = [v(One,[X^1])], - arith_eval( 1, One). -nf( X, Norm) :- number(X), !, - nf_number( X, Norm). -% -nf( rat(N,D), Norm) :- !, - nf_number( rat(N,D), Norm). -% -nf( #(Const), Norm) :- - monash_constant( Const, Value), - !, - ( arith_eval( 1, rat(1,1)) -> - nf_number( Value, Norm) % swallows #(zero) ... ok in Q - ; - arith_normalize( Value, N), % in R we want it - Norm = [v(N,[])] - ). -% -nf( -A, Norm) :- !, - nf( A, An), - arith_eval( -1, K), - nf_mul_factor( v(K,[]), An, Norm). -nf( +A, Norm) :- !, - nf( A, Norm). -% -nf( A+B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_add( An, Bn, Norm). -nf( A-B, Norm) :- !, - nf( A, An), - nf( -B, Bn), - nf_add( An, Bn, Norm). -% -nf( A*B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_mul( An, Bn, Norm). -nf( A/B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_div( Bn, An, Norm). -% -nf( Term, Norm) :- - nonlin_1( Term, Arg, Skel, Sa1), - !, - nf( Arg, An), - nf_nonlin_1( Skel, An, Sa1, Norm). -nf( Term, Norm) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - !, - nf( A1, A1n), - nf( A2, A2n), - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, Norm). -% -nf( Term, _) :- - raise_exception( type_error(nf(Term,_),1,'a numeric expression',Term)). - -nf_number( N, Res) :- - nf_number( N), - arith_normalize( N, Normal), - ( arith_eval( Normal=:=0) -> - Res = [] - ; - Res = [v(Normal,[])] - ). - -nf_number( N) :- number( N), - !. /* MC 980507 */ -nf_number( N) :- compound( N), N=rat(_,_). % sicstus - -nonlin_1( abs(X), X, abs(Y), Y). -nonlin_1( sin(X), X, sin(Y), Y). -nonlin_1( cos(X), X, cos(Y), Y). -nonlin_1( tan(X), X, tan(Y), Y). - -nonlin_2( min(A,B), A,B, min(X,Y), X, Y). -nonlin_2( max(A,B), A,B, max(X,Y), X, Y). -nonlin_2( exp(A,B), A,B, exp(X,Y), X, Y). -nonlin_2( pow(A,B), A,B, exp(X,Y), X, Y). % pow->exp -nonlin_2( A^B, A,B, exp(X,Y), X, Y). - -nf_nonlin_1( Skel, An, S1, Norm) :- - ( nf_constant( An, S1) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; - S1 = An, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - -nf_nonlin_2( Skel, A1n, A2n, S1, S2, Norm) :- - ( nf_constant( A1n, S1), - nf_constant( A2n, S2) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; Skel=exp(_,_), - nf_constant( A2n, Exp), - integerp( Exp, I) -> - nf_power( I, A1n, Norm) - ; - S1 = A1n, - S2 = A2n, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - - -nl_eval( abs(X), R) :- arith_eval( abs(X), R). -nl_eval( sin(X), R) :- arith_eval( sin(X), R). -nl_eval( cos(X), R) :- arith_eval( cos(X), R). -nl_eval( tan(X), R) :- arith_eval( tan(X), R). -% -nl_eval( min(X,Y), R) :- arith_eval( min(X,Y), R). -nl_eval( max(X,Y), R) :- arith_eval( max(X,Y), R). -nl_eval( exp(X,Y), R) :- arith_eval( exp(X,Y), R). - -monash_constant( X, _) :- var(X), !, fail. -monash_constant( p, 3.14259265). -monash_constant( pi, 3.14259265). -monash_constant( e, 2.71828182). -monash_constant( zero, Eps) :- arith_eps( Eps). - -% -% check if a Nf consists of just a constant -% -nf_constant( [], Z) :- arith_eval( 0, Z). -nf_constant( [v(K,[])], K). - -% -% this depends on the polynf ordering, i.e. [] < [X^1] ... -% -split( [], [], Z) :- arith_eval( 0, Z). -split( [First|T], H, I) :- - ( First=v(I,[]) -> - H=T - ; - arith_eval( 0, I), - H = [First|T] - ). - -% -% runtime predicate -% -:- mode nf_add( +, +, ?). -% -nf_add( [], Bs, Bs). -nf_add( [A|As], Bs, Cs) :- - nf_add( Bs, A, As, Cs). - -:- mode nf_add( +, +, +, ?). -% -nf_add( [], A, As, Cs) :- Cs = [A|As]. -nf_add( [B|Bs], A, As, Cs) :- - A = v(Ka,Pa), - B = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_case( Rel, A, As, Cs, B, Bs, Ka, Kb, Pa). - -:- mode nf_add_case( +, +, +, -, +, +, +, +, +). -% -nf_add_case( <, A, As, Cs, B, Bs, _, _, _) :- - Cs=[A|Rest], - nf_add( As, B, Bs, Rest). -nf_add_case( >, A, As, Cs, B, Bs, _, _, _) :- - Cs=[B|Rest], - nf_add( Bs, A, As, Rest). -nf_add_case( =, _, As, Cs, _, Bs, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - nf_add( As, Bs, Cs) - ; - Cs=[v(Kc,Pa)|Rest], - nf_add( As, Bs, Rest) - ). - -:- mode nf_mul( +, +, -). -% -nf_mul( A, B, Res) :- - nf_length( A, 0, LenA), - nf_length( B, 0, LenB), - nf_mul_log( LenA, A, [], LenB, B, Res). - -nf_mul_log( 0, As, As, _, _, []) :- !. -nf_mul_log( 1, [A|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A, R). -nf_mul_log( 2, [A1,A2|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A1, A1b), - nf_mul_factor_log( Lb, B, [], A2, A2b), - nf_add( A1b, A2b, R). -nf_mul_log( N, A0, A2, Lb, B, R) :- - P is N>>1, - Q is N-P, - nf_mul_log( P, A0, A1, Lb, B, Rp), - nf_mul_log( Q, A1, A2, Lb, B, Rq), - nf_add( Rp, Rq, R). - -:- mode nf_add_2( +, +, -). -% -nf_add_2( Af, Bf, Res) :- % unfold: nf_add( [Af], [Bf], Res). - Af = v(Ka,Pa), - Bf = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_2_case( Rel, Af, Bf, Res, Ka, Kb, Pa). - -:- mode nf_add_2_case( +, +, +, -, +, +, +). -% -nf_add_2_case( <, Af, Bf, [Af,Bf], _, _, _). -nf_add_2_case( >, Af, Bf, [Bf,Af], _, _, _). -nf_add_2_case( =, _, _, Res, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - Res = [] - ; - Res=[v(Kc,Pa)] - ). - -% -% multiply with a scalar =\= 0 -% -nf_mul_k( [], _, []). -nf_mul_k( [v(I,P)|Vs], K, [v(Ki,P)|Vks]) :- - arith_eval( K*I, Ki), - nf_mul_k( Vs, K, Vks). - -nf_mul_factor( v(K,[]), Sum, Res) :- !, nf_mul_k( Sum, K, Res). -nf_mul_factor( F, Sum, Res) :- - nf_length( Sum, 0, Len), - nf_mul_factor_log( Len, Sum, [], F, Res). - -nf_mul_factor_log( 0, As, As, _, []) :- !. -nf_mul_factor_log( 1, [A|As], As, F, [R]) :- !, - mult( A, F, R). -nf_mul_factor_log( 2, [A,B|As], As, F, Res) :- !, - mult( A, F, Af), - mult( B, F, Bf), - nf_add_2( Af, Bf, Res). -nf_mul_factor_log( N, A0, A2, F, R) :- - P is N>>1, - Q is N-P, - nf_mul_factor_log( P, A0, A1, F, Rp), - nf_mul_factor_log( Q, A1, A2, F, Rq), - nf_add( Rp, Rq, R). - -mult( v(Ka,La), v(Kb,Lb), v(Kc,Lc)) :- - arith_eval( Ka*Kb, Kc), - pmerge( La, Lb, Lc). - -pmerge( [], Bs, Bs). -pmerge( [A|As], Bs, Cs) :- - pmerge( Bs, A, As, Cs). - -:- mode pmerge(+,+,+,-). -% -pmerge( [], A, As, Res) :- Res = [A|As]. -pmerge( [B|Bs], A, As, Res) :- - A=Xa^Ka, - B=Xb^Kb, - compare( R, Xa, Xb), - pmerge_case( R, A, As, Res, B, Bs, Ka, Kb, Xa). - -:- mode pmerge_case( +, +, +, -, +, +, +, +, ?). -% -pmerge_case( <, A, As, Res, B, Bs, _, _, _) :- - Res = [A|Tail], - pmerge( As, B, Bs, Tail). -pmerge_case( >, A, As, Res, B, Bs, _, _, _) :- - Res = [B|Tail], - pmerge( Bs, A, As, Tail). -pmerge_case( =, _, As, Res, _, Bs, Ka, Kb, Xa) :- - Kc is Ka+Kb, - ( Kc=:=0 -> - pmerge( As, Bs, Res) - ; - Res = [Xa^Kc|Tail], - pmerge( As, Bs, Tail) - ). - -nf_div( [], _, _) :- !, zero_division. -nf_div( [v(K,P)], Sum, Res) :- !, - arith_eval( 1/K, Ki), - mult_exp( P, -1, Pi), - nf_mul_factor( v(Ki,Pi), Sum, Res). -nf_div( D, A, [v(One,[(A/D)^1])]) :- - arith_eval( 1, One). - -zero_division :- fail. % raise_exception(_) ? - -mult_exp( [], _, []). -mult_exp( [X^P|Xs], K, [X^I|Tail]) :- - I is K*P, - mult_exp( Xs, K, Tail). - -% -% raise to integer powers -% -% | ?- time({(1+X+Y+Z)^15=0}). -% Timing 00:00:02.610 2.610 iterative -% Timing 00:00:00.660 0.660 binomial -nf_power( N, Sum, Norm) :- - integer( N), - compare( Rel, N, 0), - ( Rel = < -> - Pn is -N, - % nf_power_pos( Pn, Sum, Inorm), - binom( Sum, Pn, Inorm), - arith_eval( 1, One), - nf_div( Inorm, [v(One,[])], Norm) - ; Rel = > -> - % nf_power_pos( N, Sum, Norm) - binom( Sum, N, Norm) - ; Rel = = -> % 0^0 is indeterminate but we say 1 - arith_eval( 1, One), - Norm = [v(One,[])] - ). - - -% -% N>0 -% -nf_power_pos( 1, Sum, Norm) :- !, Sum = Norm. -nf_power_pos( N, Sum, Norm) :- - N1 is N-1, - nf_power_pos( N1, Sum, Pn1), - nf_mul( Sum, Pn1, Norm). - -% -% N>0 -% -binom( Sum, 1, Power) :- !, Power = Sum. -binom( [], _, []). -binom( [A|Bs], N, Power) :- - ( Bs=[] -> - nf_power_factor( A, N, Ap), - Power = [Ap] - ; Bs=[_|_] -> - arith_eval( 1, One), - factor_powers( N, A, v(One,[]), Pas), - sum_powers( N, Bs, [v(One,[])], Pbs, []), - combine_powers( Pas, Pbs, 0, N, 1, [], Power) - ). - -combine_powers( [], [], _, _, _, Pi, Pi). -combine_powers( [A|As], [B|Bs], L, R, C, Pi, Po) :- - nf_mul( A, B, Ab), - arith_normalize( C, Cn), - nf_mul_k( Ab, Cn, Abc), - nf_add( Abc, Pi, Pii), - L1 is L+1, - R1 is R-1, - C1 is C*R//L1, - combine_powers( As, Bs, L1, R1, C1, Pii, Po). - - -nf_power_factor( v(K,P), N, v(Kn,Pn)) :- - arith_normalize( N, Nn), - arith_eval( exp(K,Nn), Kn), - mult_exp( P, N, Pn). - -factor_powers( 0, _, Prev, [[Prev]]) :- !. -factor_powers( N, F, Prev, [[Prev]|Ps]) :- - N1 is N-1, - mult( Prev, F, Next), - factor_powers( N1, F, Next, Ps). - -sum_powers( 0, _, Prev, [Prev|Lt], Lt) :- !. -sum_powers( N, S, Prev, L0, Lt) :- - N1 is N-1, - nf_mul( S, Prev, Next), - sum_powers( N1, S, Next, L0, [Prev|Lt]). - -% ------------------------------------------------------------------------------ - -repair( Sum, Norm) :- - nf_length( Sum, 0, Len), - repair_log( Len, Sum, [], Norm). - -repair_log( 0, As, As, []) :- !. -repair_log( 1, [v(Ka,Pa)|As], As, R) :- !, - repair_term( Ka, Pa, R). -repair_log( 2, [v(Ka,Pa),v(Kb,Pb)|As], As, R) :- !, - repair_term( Ka, Pa, Ar), - repair_term( Kb, Pb, Br), - nf_add( Ar, Br, R). -repair_log( N, A0, A2, R) :- - P is N>>1, - Q is N-P, - repair_log( P, A0, A1, Rp), - repair_log( Q, A1, A2, Rq), - nf_add( Rp, Rq, R). - - -repair_term( K, P, Norm) :- - length( P, Len), - arith_eval( 1, One), - repair_p_log( Len, P, [], Pr, [v(One,[])], Sum), - nf_mul_factor( v(K,Pr), Sum, Norm). - -repair_p_log( 0, Ps, Ps, [], L0, L0) :- !. -repair_p_log( 1, [X^P|Ps], Ps, R, L0, L1) :- !, - repair_p( X, P, R, L0, L1). -repair_p_log( 2, [X^Px,Y^Py|Ps], Ps, R, L0,L2) :- !, - repair_p( X, Px, Rx, L0, L1), - repair_p( Y, Py, Ry, L1, L2), - pmerge( Rx, Ry, R). -repair_p_log( N, P0, P2, R, L0, L2) :- - P is N>>1, - Q is N-P, - repair_p_log( P, P0, P1, Rp, L0, L1), - repair_p_log( Q, P1, P2, Rq, L1, L2), - pmerge( Rp, Rq, R). - - -repair_p( Term, P, [Term^P], L0, L0) :- var( Term). -repair_p( Term, P, [], L0, L1) :- nonvar( Term), - repair_p_one( Term, TermN), - nf_power( P, TermN, TermNP), - nf_mul( TermNP, L0, L1). - -% -% An undigested term a/b is distinguished from an -% digested one by the fact that its arguments are -% digested -> cuts after repair of args! -% -repair_p_one( Term, TermN) :- - nf_number( Term, TermN), % freq. shortcut for nf/2 case below - !. -repair_p_one( A1/A2, TermN) :- - repair( A1, A1n), - repair( A2, A2n), - !, - nf_div( A2n, A1n, TermN). -repair_p_one( Term, TermN) :- - nonlin_1( Term, Arg, Skel, Sa), - repair( Arg, An), - !, - nf_nonlin_1( Skel, An, Sa, TermN). -repair_p_one( Term, TermN) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - repair( A1, A1n), - repair( A2, A2n), - !, - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, TermN). -repair_p_one( Term, TermN) :- - nf( Term, TermN). - -:- mode nf_length( +, +, -). -% -nf_length( [], Li, Li). -nf_length( [_|R], Li, Lo) :- - Lii is Li+1, - nf_length( R, Lii, Lo). - -% ------------------------------------------------------------------------------ - -nf2term( [], Z) :- arith_eval( 0, Z). -nf2term( [F|Fs], T) :- - f02t( F, T0), - yfx( Fs, T0, T). - -yfx( [], T0, T0). -yfx( [F|Fs], T0, TN) :- - fn2t( F, Ft, Op), - T1 =.. [Op,T0,Ft], - yfx( Fs, T1, TN). - -f02t( v(K,P), T) :- - ( P = [] -> - T = K - ; arith_eval( K=:=1) -> - p2term( P, T) - ; arith_eval( K=:= -1) -> - T = -Pt, - p2term( P, Pt) - ; - T = K*Pt, - p2term( P, Pt) - ). - -fn2t( v(K,P), Term, Op) :- - ( arith_eval( K=:=1) -> - Term = Pt, Op = + - ; arith_eval( K=:= -1) -> - Term = Pt, Op = - - ; arith_eval( K<0) -> - arith_eval( -K, Kf), - Term = Kf*Pt, Op = - - ; - Term = K*Pt, Op = + - ), - p2term( P, Pt). - -p2term( [X^P|Xs], Term) :- - ( Xs=[] -> - pe2term( X, Xt), - exp2term( P, Xt, Term) - ; Xs=[_|_] -> - Term = Xst*Xtp, - pe2term( X, Xt), - exp2term( P, Xt, Xtp), - p2term( Xs, Xst) - ). - -exp2term( 1, X, X) :- !. -exp2term(-1, X, One/X) :- !, arith_eval( 1, One). -exp2term( P, X, Term) :- - arith_normalize( P, Pn), - % Term = exp(X,Pn). - Term = X^Pn. - -pe2term( X, Term) :- var(X), Term = X. -pe2term( X, Term) :- nonvar(X), - X =.. [F|Args], - pe2term_args( Args, Argst), - Term =.. [F|Argst]. - -pe2term_args( [], []). -pe2term_args( [A|As], [T|Ts]) :- - nf2term( A, T), - pe2term_args( As, Ts). - diff --git a/CLPQR/clpqr/nf.yap b/CLPQR/clpqr/nf.yap deleted file mode 100644 index 0ecf530d3..000000000 --- a/CLPQR/clpqr/nf.yap +++ /dev/null @@ -1,835 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nf.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- use_module( library(terms), [term_variables/2]). -:- use_module( geler). - -% ------------------------------------------------------------------------- - -{ Rel } :- var( Rel), !, raise_exception(instantiation_error({Rel},1)). -{ R,Rs } :- !, {R}, {Rs}. -{ R;Rs } :- !, ({R} ; {Rs}). % for entailment checking -{ L < R } :- !, nf( L-R, Nf), submit_lt( Nf). -{ L > R } :- !, nf( R-L, Nf), submit_lt( Nf). -{ L =< R } :- !, nf( L-R, Nf), submit_le( Nf). -{ <=(L,R) } :- !, nf( L-R, Nf), submit_le( Nf). -{ L >= R } :- !, nf( R-L, Nf), submit_le( Nf). -{ L =\= R } :- !, nf( L-R, Nf), submit_ne( Nf). -{ L =:= R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ L = R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ Rel } :- raise_exception( type_error({Rel},1,'a constraint',Rel)). - -% -% s -> c = ~s v c = ~(s /\ ~c) -% where s is the store and c is the constraint for which -% we want to know whether it is entailed. -% -entailed( C) :- - negate( C, Cn), - \+ { Cn }. - -negate( Rel, _) :- var( Rel), !, raise_exception(instantiation_error(entailed(Rel),1)). -negate( (A,B), (Na;Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( (A;B), (Na,Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( A=B) :- !. -negate( A>B, A=B) :- !. -negate( A>=B, A A=0 - b4) nonlinear -> geler - c) Nf=[A,B|Rest] - c1) A=k - c11) B=X^+-1, Rest=[] -> B= - c12) invertible(A,B) - c13) linear(B|Rest) - c14) geler - c2) linear(Nf) - c3) nonlinear -> geler -*/ -submit_eq( []). % trivial success -submit_eq( [T|Ts]) :- - submit_eq( Ts, T). - -submit_eq( [], A) :- submit_eq_b( A). -submit_eq( [B|Bs], A) :- submit_eq_c( A, B, Bs). - -submit_eq_b( v(_,[])) :- !, fail. % b1: trivial failure -submit_eq_b( v(_,[X^P])) :- % b2,b3: n*x^p=0 -> x=0 - var( X), - P > 0, - !, - arith_eval( 0, Z), - export_binding( X, Z). -submit_eq_b( v(_,[NL^1])) :- % b2 - nonvar( NL), - arith_eval( 0, Z), - nl_invertible( NL, X, Z, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_b( Term) :- % b4 - term_variables( Term, Vs), - geler( Vs, resubmit_eq([Term])). - -submit_eq_c( v(I,[]), B, Rest) :- !, - submit_eq_c1( Rest, B, I). -submit_eq_c( A, B, Rest) :- % c2 - A=v(_,[X^1]), var(X), - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - Hom = [A,B|Rest], - % 'solve_='( Hom). - nf_length( Hom, 0, Len), - log_deref( Len, Hom, [], HomD), - solve( HomD). -submit_eq_c( A, B, Rest) :- % c3 - Norm = [A,B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -submit_eq_c1( [], v(K,[X^P]), I) :- % c11 - var( X), - ( P = 1, !, arith_eval( -I/K, Val), export_binding( X, Val) - ; P = -1, !, arith_eval( -K/I, Val), export_binding( X, Val) - ). -submit_eq_c1( [], v(K,[NL^P]), I) :- % c12 - nonvar( NL), - ( P = 1, arith_eval( -I/K, Y) - ; P = -1, arith_eval( -K/I, Y) - ), - nl_invertible( NL, X, Y, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_c1( Rest, B, I) :- % c13 - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - % 'solve_='( [v(I,[]),B|Rest]). - Hom = [B|Rest], - nf_length( Hom, 0, Len), - normalize_scalar( I, Nonvar), - log_deref( Len, Hom, [], HomD), - add_linear_11( Nonvar, HomD, LinD), - solve( LinD). -submit_eq_c1( Rest, B, I) :- % c14 - Norm = [v(I,[]),B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -% ----------------------------------------------------------------------- - -submit_lt( []) :- fail. % trivial failure -submit_lt( [A|As]) :- - submit_lt( As, A). - -submit_lt( [], v(K,P)) :- submit_lt_b( P, K). -submit_lt( [B|Bs], A) :- submit_lt_c( Bs, A, B). - -submit_lt_b( [], I) :- !, arith_eval( I<0). -submit_lt_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_s_p_0( X) - ; - ineq_one_s_n_0( X) - ). -submit_lt_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_lt([v(K,P)])). - -submit_lt_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( strict, Y, K, I). -submit_lt_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_lt(Norm)) - ). - -submit_le( []). % trivial success -submit_le( [A|As]) :- - submit_le( As, A). - -submit_le( [], v(K,P)) :- submit_le_b( P, K). -submit_le( [B|Bs], A) :- submit_le_c( Bs, A, B). - -submit_le_b( [], I) :- !, arith_eval( I=<0). -submit_le_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_n_p_0( X) - ; - ineq_one_n_n_0( X) - ). -submit_le_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_le([v(K,P)])). - -submit_le_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( nonstrict, Y, K, I). -submit_le_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_=<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_le(Norm)) - ). - -submit_ne( Norm1) :- - ( nf_constant( Norm1, K) -> - arith_eval( K=\=0) - ; linear( Norm1) -> - 'solve_=\\='( Norm1) - ; - term_variables( Norm1, Vs), - geler( Vs, resubmit_ne(Norm1)) - ). - - -linear( []). -linear( v(_,Ps)) :- linear_ps( Ps). -linear( [A|As]) :- - linear( A), - linear( As). - -linear_ps( []). -linear_ps( [V^1]) :- var( V). % excludes sin(_), ... - -% -% Goal delays until Term gets linear. -% At this time, Var will be bound to the normalform of Term. -% -:- meta_predicate wait_linear( ?, ?, :). -% -wait_linear( Term, Var, Goal) :- - nf( Term, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% -% geler clients -% -resubmit_eq( N) :- - repair( N, Norm), - submit_eq( Norm). - -resubmit_lt( N) :- - repair( N, Norm), - submit_lt( Norm). - -resubmit_le( N) :- - repair( N, Norm), - submit_le( Norm). - -resubmit_ne( N) :- - repair( N, Norm), - submit_ne( Norm). - -wait_linear_retry( Nf0, Var, Goal) :- - repair( Nf0, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% ----------------------------------------------------------------------- - -/* -invertible( [v(Mone,[]),v(One,[X^Px,Y^Py])], Norm) :- - Px+Py =:= 0, - abs(Px) mod 2 =:= 1, % odd powers only ... - arith_eval( 1, One), - arith_eval( -1, Mone), - !, - ( Px < 0 -> - {X=\=0} - ; - {Y=\=0} - ), - nf( X-Y, Norm). % x=y -*/ - -nl_invertible( sin(X), X, Y, Res) :- arith_eval( asin(Y), Res). -nl_invertible( cos(X), X, Y, Res) :- arith_eval( acos(Y), Res). -nl_invertible( tan(X), X, Y, Res) :- arith_eval( atan(Y), Res). -nl_invertible( exp(B,C), X, A, Res) :- - ( nf_constant( B, Kb) -> - arith_eval(A>0), - arith_eval(Kb>0), - arith_eval(Kb=\=1), - X = C, - arith_eval( log(A)/log(Kb), Res) - ; nf_constant( C, Kc), - \+ (arith_eval(A=:=0),arith_eval(Kc=<0)), - X = B, - arith_eval( exp(A,1/Kc), Res) - ). - -% ----------------------------------------------------------------------- - -nf( X, Norm) :- var(X), !, - Norm = [v(One,[X^1])], - arith_eval( 1, One). -nf( X, Norm) :- number(X), !, - nf_number( X, Norm). -% -nf( rat(N,D), Norm) :- !, - nf_number( rat(N,D), Norm). -% -nf( #(Const), Norm) :- - monash_constant( Const, Value), - !, - ( arith_eval( 1, rat(1,1)) -> - nf_number( Value, Norm) % swallows #(zero) ... ok in Q - ; - arith_normalize( Value, N), % in R we want it - Norm = [v(N,[])] - ). -% -nf( -A, Norm) :- !, - nf( A, An), - arith_eval( -1, K), - nf_mul_factor( v(K,[]), An, Norm). -nf( +A, Norm) :- !, - nf( A, Norm). -% -nf( A+B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_add( An, Bn, Norm). -nf( A-B, Norm) :- !, - nf( A, An), - nf( -B, Bn), - nf_add( An, Bn, Norm). -% -nf( A*B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_mul( An, Bn, Norm). -nf( A/B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_div( Bn, An, Norm). -% -nf( Term, Norm) :- - nonlin_1( Term, Arg, Skel, Sa1), - !, - nf( Arg, An), - nf_nonlin_1( Skel, An, Sa1, Norm). -nf( Term, Norm) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - !, - nf( A1, A1n), - nf( A2, A2n), - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, Norm). -% -nf( Term, _) :- - raise_exception( type_error(nf(Term,_),1,'a numeric expression',Term)). - -nf_number( N, Res) :- - nf_number( N), - arith_normalize( N, Normal), - ( arith_eval( Normal=:=0) -> - Res = [] - ; - Res = [v(Normal,[])] - ). - -nf_number( N) :- number( N), - !. /* MC 980507 */ -nf_number( N) :- compound( N), N=rat(_,_). % sicstus - -nonlin_1( abs(X), X, abs(Y), Y). -nonlin_1( sin(X), X, sin(Y), Y). -nonlin_1( cos(X), X, cos(Y), Y). -nonlin_1( tan(X), X, tan(Y), Y). - -nonlin_2( min(A,B), A,B, min(X,Y), X, Y). -nonlin_2( max(A,B), A,B, max(X,Y), X, Y). -nonlin_2( exp(A,B), A,B, exp(X,Y), X, Y). -nonlin_2( pow(A,B), A,B, exp(X,Y), X, Y). % pow->exp -nonlin_2( A^B, A,B, exp(X,Y), X, Y). - -nf_nonlin_1( Skel, An, S1, Norm) :- - ( nf_constant( An, S1) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; - S1 = An, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - -nf_nonlin_2( Skel, A1n, A2n, S1, S2, Norm) :- - ( nf_constant( A1n, S1), - nf_constant( A2n, S2) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; Skel=exp(_,_), - nf_constant( A2n, Exp), - integerp( Exp, I) -> - nf_power( I, A1n, Norm) - ; - S1 = A1n, - S2 = A2n, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - - -nl_eval( abs(X), R) :- arith_eval( abs(X), R). -nl_eval( sin(X), R) :- arith_eval( sin(X), R). -nl_eval( cos(X), R) :- arith_eval( cos(X), R). -nl_eval( tan(X), R) :- arith_eval( tan(X), R). -% -nl_eval( min(X,Y), R) :- arith_eval( min(X,Y), R). -nl_eval( max(X,Y), R) :- arith_eval( max(X,Y), R). -nl_eval( exp(X,Y), R) :- arith_eval( exp(X,Y), R). - -monash_constant( X, _) :- var(X), !, fail. -monash_constant( p, 3.14259265). -monash_constant( pi, 3.14259265). -monash_constant( e, 2.71828182). -monash_constant( zero, Eps) :- arith_eps( Eps). - -% -% check if a Nf consists of just a constant -% -nf_constant( [], Z) :- arith_eval( 0, Z). -nf_constant( [v(K,[])], K). - -% -% this depends on the polynf ordering, i.e. [] < [X^1] ... -% -split( [], [], Z) :- arith_eval( 0, Z). -split( [First|T], H, I) :- - ( First=v(I,[]) -> - H=T - ; - arith_eval( 0, I), - H = [First|T] - ). - -% -% runtime predicate -% -:- mode nf_add( +, +, ?). -% -nf_add( [], Bs, Bs). -nf_add( [A|As], Bs, Cs) :- - nf_add( Bs, A, As, Cs). - -:- mode nf_add( +, +, +, ?). -% -nf_add( [], A, As, Cs) :- Cs = [A|As]. -nf_add( [B|Bs], A, As, Cs) :- - A = v(Ka,Pa), - B = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_case( Rel, A, As, Cs, B, Bs, Ka, Kb, Pa). - -:- mode nf_add_case( +, +, +, -, +, +, +, +, +). -% -nf_add_case( <, A, As, Cs, B, Bs, _, _, _) :- - Cs=[A|Rest], - nf_add( As, B, Bs, Rest). -nf_add_case( >, A, As, Cs, B, Bs, _, _, _) :- - Cs=[B|Rest], - nf_add( Bs, A, As, Rest). -nf_add_case( =, _, As, Cs, _, Bs, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - nf_add( As, Bs, Cs) - ; - Cs=[v(Kc,Pa)|Rest], - nf_add( As, Bs, Rest) - ). - -:- mode nf_mul( +, +, -). -% -nf_mul( A, B, Res) :- - nf_length( A, 0, LenA), - nf_length( B, 0, LenB), - nf_mul_log( LenA, A, [], LenB, B, Res). - -nf_mul_log( 0, As, As, _, _, []) :- !. -nf_mul_log( 1, [A|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A, R). -nf_mul_log( 2, [A1,A2|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A1, A1b), - nf_mul_factor_log( Lb, B, [], A2, A2b), - nf_add( A1b, A2b, R). -nf_mul_log( N, A0, A2, Lb, B, R) :- - P is N>>1, - Q is N-P, - nf_mul_log( P, A0, A1, Lb, B, Rp), - nf_mul_log( Q, A1, A2, Lb, B, Rq), - nf_add( Rp, Rq, R). - -:- mode nf_add_2( +, +, -). -% -nf_add_2( Af, Bf, Res) :- % unfold: nf_add( [Af], [Bf], Res). - Af = v(Ka,Pa), - Bf = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_2_case( Rel, Af, Bf, Res, Ka, Kb, Pa). - -:- mode nf_add_2_case( +, +, +, -, +, +, +). -% -nf_add_2_case( <, Af, Bf, [Af,Bf], _, _, _). -nf_add_2_case( >, Af, Bf, [Bf,Af], _, _, _). -nf_add_2_case( =, _, _, Res, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - Res = [] - ; - Res=[v(Kc,Pa)] - ). - -% -% multiply with a scalar =\= 0 -% -nf_mul_k( [], _, []). -nf_mul_k( [v(I,P)|Vs], K, [v(Ki,P)|Vks]) :- - arith_eval( K*I, Ki), - nf_mul_k( Vs, K, Vks). - -nf_mul_factor( v(K,[]), Sum, Res) :- !, nf_mul_k( Sum, K, Res). -nf_mul_factor( F, Sum, Res) :- - nf_length( Sum, 0, Len), - nf_mul_factor_log( Len, Sum, [], F, Res). - -nf_mul_factor_log( 0, As, As, _, []) :- !. -nf_mul_factor_log( 1, [A|As], As, F, [R]) :- !, - mult( A, F, R). -nf_mul_factor_log( 2, [A,B|As], As, F, Res) :- !, - mult( A, F, Af), - mult( B, F, Bf), - nf_add_2( Af, Bf, Res). -nf_mul_factor_log( N, A0, A2, F, R) :- - P is N>>1, - Q is N-P, - nf_mul_factor_log( P, A0, A1, F, Rp), - nf_mul_factor_log( Q, A1, A2, F, Rq), - nf_add( Rp, Rq, R). - -mult( v(Ka,La), v(Kb,Lb), v(Kc,Lc)) :- - arith_eval( Ka*Kb, Kc), - pmerge( La, Lb, Lc). - -pmerge( [], Bs, Bs). -pmerge( [A|As], Bs, Cs) :- - pmerge( Bs, A, As, Cs). - -:- mode pmerge(+,+,+,-). -% -pmerge( [], A, As, Res) :- Res = [A|As]. -pmerge( [B|Bs], A, As, Res) :- - A=Xa^Ka, - B=Xb^Kb, - compare( R, Xa, Xb), - pmerge_case( R, A, As, Res, B, Bs, Ka, Kb, Xa). - -:- mode pmerge_case( +, +, +, -, +, +, +, +, ?). -% -pmerge_case( <, A, As, Res, B, Bs, _, _, _) :- - Res = [A|Tail], - pmerge( As, B, Bs, Tail). -pmerge_case( >, A, As, Res, B, Bs, _, _, _) :- - Res = [B|Tail], - pmerge( Bs, A, As, Tail). -pmerge_case( =, _, As, Res, _, Bs, Ka, Kb, Xa) :- - Kc is Ka+Kb, - ( Kc=:=0 -> - pmerge( As, Bs, Res) - ; - Res = [Xa^Kc|Tail], - pmerge( As, Bs, Tail) - ). - -nf_div( [], _, _) :- !, zero_division. -nf_div( [v(K,P)], Sum, Res) :- !, - arith_eval( 1/K, Ki), - mult_exp( P, -1, Pi), - nf_mul_factor( v(Ki,Pi), Sum, Res). -nf_div( D, A, [v(One,[(A/D)^1])]) :- - arith_eval( 1, One). - -zero_division :- fail. % raise_exception(_) ? - -mult_exp( [], _, []). -mult_exp( [X^P|Xs], K, [X^I|Tail]) :- - I is K*P, - mult_exp( Xs, K, Tail). - -% -% raise to integer powers -% -% | ?- time({(1+X+Y+Z)^15=0}). -% Timing 00:00:02.610 2.610 iterative -% Timing 00:00:00.660 0.660 binomial -nf_power( N, Sum, Norm) :- - integer( N), - compare( Rel, N, 0), - ( Rel = < -> - Pn is -N, - % nf_power_pos( Pn, Sum, Inorm), - binom( Sum, Pn, Inorm), - arith_eval( 1, One), - nf_div( Inorm, [v(One,[])], Norm) - ; Rel = > -> - % nf_power_pos( N, Sum, Norm) - binom( Sum, N, Norm) - ; Rel = = -> % 0^0 is indeterminate but we say 1 - arith_eval( 1, One), - Norm = [v(One,[])] - ). - - -% -% N>0 -% -nf_power_pos( 1, Sum, Norm) :- !, Sum = Norm. -nf_power_pos( N, Sum, Norm) :- - N1 is N-1, - nf_power_pos( N1, Sum, Pn1), - nf_mul( Sum, Pn1, Norm). - -% -% N>0 -% -binom( Sum, 1, Power) :- !, Power = Sum. -binom( [], _, []). -binom( [A|Bs], N, Power) :- - ( Bs=[] -> - nf_power_factor( A, N, Ap), - Power = [Ap] - ; Bs=[_|_] -> - arith_eval( 1, One), - factor_powers( N, A, v(One,[]), Pas), - sum_powers( N, Bs, [v(One,[])], Pbs, []), - combine_powers( Pas, Pbs, 0, N, 1, [], Power) - ). - -combine_powers( [], [], _, _, _, Pi, Pi). -combine_powers( [A|As], [B|Bs], L, R, C, Pi, Po) :- - nf_mul( A, B, Ab), - arith_normalize( C, Cn), - nf_mul_k( Ab, Cn, Abc), - nf_add( Abc, Pi, Pii), - L1 is L+1, - R1 is R-1, - C1 is C*R//L1, - combine_powers( As, Bs, L1, R1, C1, Pii, Po). - - -nf_power_factor( v(K,P), N, v(Kn,Pn)) :- - arith_normalize( N, Nn), - arith_eval( exp(K,Nn), Kn), - mult_exp( P, N, Pn). - -factor_powers( 0, _, Prev, [[Prev]]) :- !. -factor_powers( N, F, Prev, [[Prev]|Ps]) :- - N1 is N-1, - mult( Prev, F, Next), - factor_powers( N1, F, Next, Ps). - -sum_powers( 0, _, Prev, [Prev|Lt], Lt) :- !. -sum_powers( N, S, Prev, L0, Lt) :- - N1 is N-1, - nf_mul( S, Prev, Next), - sum_powers( N1, S, Next, L0, [Prev|Lt]). - -% ------------------------------------------------------------------------------ - -repair( Sum, Norm) :- - nf_length( Sum, 0, Len), - repair_log( Len, Sum, [], Norm). - -repair_log( 0, As, As, []) :- !. -repair_log( 1, [v(Ka,Pa)|As], As, R) :- !, - repair_term( Ka, Pa, R). -repair_log( 2, [v(Ka,Pa),v(Kb,Pb)|As], As, R) :- !, - repair_term( Ka, Pa, Ar), - repair_term( Kb, Pb, Br), - nf_add( Ar, Br, R). -repair_log( N, A0, A2, R) :- - P is N>>1, - Q is N-P, - repair_log( P, A0, A1, Rp), - repair_log( Q, A1, A2, Rq), - nf_add( Rp, Rq, R). - - -repair_term( K, P, Norm) :- - length( P, Len), - arith_eval( 1, One), - repair_p_log( Len, P, [], Pr, [v(One,[])], Sum), - nf_mul_factor( v(K,Pr), Sum, Norm). - -repair_p_log( 0, Ps, Ps, [], L0, L0) :- !. -repair_p_log( 1, [X^P|Ps], Ps, R, L0, L1) :- !, - repair_p( X, P, R, L0, L1). -repair_p_log( 2, [X^Px,Y^Py|Ps], Ps, R, L0,L2) :- !, - repair_p( X, Px, Rx, L0, L1), - repair_p( Y, Py, Ry, L1, L2), - pmerge( Rx, Ry, R). -repair_p_log( N, P0, P2, R, L0, L2) :- - P is N>>1, - Q is N-P, - repair_p_log( P, P0, P1, Rp, L0, L1), - repair_p_log( Q, P1, P2, Rq, L1, L2), - pmerge( Rp, Rq, R). - - -%vsc: added ! (01/06/06) -repair_p( Term, P, [Term^P], L0, L0) :- var( Term), !. -repair_p( Term, P, [], L0, L1) :- nonvar( Term), - repair_p_one( Term, TermN), - nf_power( P, TermN, TermNP), - nf_mul( TermNP, L0, L1). - -% -% An undigested term a/b is distinguished from an -% digested one by the fact that its arguments are -% digested -> cuts after repair of args! -% -repair_p_one( Term, TermN) :- - nf_number( Term, TermN), % freq. shortcut for nf/2 case below - !. -repair_p_one( A1/A2, TermN) :- - repair( A1, A1n), - repair( A2, A2n), - !, - nf_div( A2n, A1n, TermN). -repair_p_one( Term, TermN) :- - nonlin_1( Term, Arg, Skel, Sa), - repair( Arg, An), - !, - nf_nonlin_1( Skel, An, Sa, TermN). -repair_p_one( Term, TermN) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - repair( A1, A1n), - repair( A2, A2n), - !, - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, TermN). -repair_p_one( Term, TermN) :- - nf( Term, TermN). - -:- mode nf_length( +, +, -). -% -nf_length( [], Li, Li). -nf_length( [_|R], Li, Lo) :- - Lii is Li+1, - nf_length( R, Lii, Lo). - -% ------------------------------------------------------------------------------ - -nf2term( [], Z) :- arith_eval( 0, Z). -nf2term( [F|Fs], T) :- - f02t( F, T0), - yfx( Fs, T0, T). - -yfx( [], T0, T0). -yfx( [F|Fs], T0, TN) :- - fn2t( F, Ft, Op), - T1 =.. [Op,T0,Ft], - yfx( Fs, T1, TN). - -f02t( v(K,P), T) :- - ( P = [] -> - T = K - ; arith_eval( K=:=1) -> - p2term( P, T) - ; arith_eval( K=:= -1) -> - T = -Pt, - p2term( P, Pt) - ; - T = K*Pt, - p2term( P, Pt) - ). - -fn2t( v(K,P), Term, Op) :- - ( arith_eval( K=:=1) -> - Term = Pt, Op = + - ; arith_eval( K=:= -1) -> - Term = Pt, Op = - - ; arith_eval( K<0) -> - arith_eval( -K, Kf), - Term = Kf*Pt, Op = - - ; - Term = K*Pt, Op = + - ), - p2term( P, Pt). - -p2term( [X^P|Xs], Term) :- - ( Xs=[] -> - pe2term( X, Xt), - exp2term( P, Xt, Term) - ; Xs=[_|_] -> - Term = Xst*Xtp, - pe2term( X, Xt), - exp2term( P, Xt, Xtp), - p2term( Xs, Xst) - ). - -exp2term( 1, X, X) :- !. -exp2term(-1, X, One/X) :- !, arith_eval( 1, One). -exp2term( P, X, Term) :- - arith_normalize( P, Pn), - % Term = exp(X,Pn). - Term = X^Pn. - -pe2term( X, Term) :- var(X), Term = X. -pe2term( X, Term) :- nonvar(X), - X =.. [F|Args], - pe2term_args( Args, Argst), - Term =.. [F|Argst]. - -pe2term_args( [], []). -pe2term_args( [A|As], [T|Ts]) :- - nf2term( A, T), - pe2term_args( As, Ts). - diff --git a/CLPQR/clpqr/ordering.pl b/CLPQR/clpqr/ordering.pl deleted file mode 100644 index 3a0df5cac..000000000 --- a/CLPQR/clpqr/ordering.pl +++ /dev/null @@ -1,136 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: ordering.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Collect ordering constraints -% Produce an arrangement via toplogical sorting -% -% - -:- use_module( library(lists), [append/3]). - -:- use_module( library(ugraphs), - [ - top_sort/2, - add_edges/3, - add_vertices/3 - ]). - -ordering( X) :- var(X), !, fail. -ordering( A>B) :- !, ordering( B - Res = [Xnorm|Xsn], - normalize_vertices( Xs, Xsn) - ; - normalize_vertices( Xs, Res) - ). - -% -% get rid of nonvar vertices/edges, and turn V-[V] into V-[] -% -normalize_vertex( X, Nbs, X-Nbsss) :- - var(X), - sort( Nbs, Nbss), - strip_nonvar( Nbss, X, Nbsss). - -strip_nonvar( [], _, []). -strip_nonvar( [X|Xs], Y, Res) :- - ( X==Y -> strip_nonvar( Xs, Y, Res) - ; var(X) -> - Res=[X|Stripped], - strip_nonvar( Xs, Y, Stripped) - ; nonvar(X), - Res=[] % because Vars []. -gen_edges( [X|Xs]) --> - gen_edges( Xs, X), - gen_edges( Xs). - -gen_edges( [], _) --> []. -gen_edges( [Y|Ys], X) --> - [ X-Y ], - gen_edges( Ys, X). - -% -% map k-La,k-Lb.... into k-LaLb -% -group( [], []). -group( [K-Kl|Ks], Res) :- - group( Ks, K, Kl, Res). - -group( [], K, Kl, [K-Kl]). -group( [L-Ll|Ls], K, Kl, Res) :- - ( K==L -> - append( Kl, Ll, KLl), - group( Ls, K, KLl, Res) - ; - Res = [K-Kl|Tail], - group( Ls, L, Ll, Tail) - ). - diff --git a/CLPQR/clpqr/ordering.yap b/CLPQR/clpqr/ordering.yap deleted file mode 100644 index e728943b2..000000000 --- a/CLPQR/clpqr/ordering.yap +++ /dev/null @@ -1,135 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: ordering.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Collect ordering constraints -% Produce an arrangement via toplogical sorting -% -% - -:- use_module( library(lists), [append/3]). - -:- use_module( library(ugraphs), - [ - top_sort/2, - add_edges/3, - add_vertices/3 - ]). - -ordering( X) :- var(X), !, fail. -ordering( A>B) :- !, ordering( B - Res = [Xnorm|Xsn], - normalize_vertices( Xs, Xsn) - ; - normalize_vertices( Xs, Res) - ). - -% -% get rid of nonvar vertices/edges, and turn V-[V] into V-[] -% -normalize_vertex( X, Nbs, X-Nbsss) :- - var(X), - sort( Nbs, Nbss), - strip_nonvar( Nbss, X, Nbsss). - -strip_nonvar( [], _, []). -strip_nonvar( [X|Xs], Y, Res) :- - ( X==Y -> strip_nonvar( Xs, Y, Res) - ; var(X) -> - Res=[X|Stripped], - strip_nonvar( Xs, Y, Stripped) - ; nonvar(X), - Res=[] % because Vars []. -gen_edges( [X|Xs]) --> - gen_edges( Xs, X), - gen_edges( Xs). - -gen_edges( [], _) --> []. -gen_edges( [Y|Ys], X) --> - [ X-Y ], - gen_edges( Ys, X). - -% -% map k-La,k-Lb.... into k-LaLb -% -group( [], []). -group( [K-Kl|Ks], Res) :- - group( Ks, K, Kl, Res). - -group( [], K, Kl, [K-Kl]). -group( [L-Ll|Ls], K, Kl, Res) :- - ( K==L -> - append( Kl, Ll, KLl), - group( Ls, K, KLl, Res) - ; - Res = [K-Kl|Tail], - group( Ls, L, Ll, Tail) - ). - diff --git a/CLPQR/clpqr/printf.pl b/CLPQR/clpqr/printf.pl deleted file mode 100644 index a9d5b9da6..000000000 --- a/CLPQR/clpqr/printf.pl +++ /dev/null @@ -1,139 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: printf.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% a mockup for clp(R) printf/2 -% - -:- module( printf, [printf/1,printf/2]). - -printf( A) :- printf( A, []). - -printf([], _). -/* obsolete as of sicstus3 with escape sequences -printf([0'\,Ch|Fmt],Args) :- !, - printf_special(Ch), - printf(Fmt,Args). -*/ -printf([0'%|Spec],Args) :- !, - argspec(Args,Restargs,Spec,Rest), - printf(Rest,Restargs). -printf([Ch|Fmt],Args) :- - put(Ch), - printf(Fmt,Args). - -printf_special( 0'n) :- !, nl. -printf_special( 0't) :- !, put( 9). -printf_special( 0'r) :- !, put(13). -printf_special( 0'b) :- !, put( 8). -printf_special( 0'f) :- !, put(12). -printf_special( N) :- put(N). - -argspec(Ai,Ao) --> format_prefix( Prefix), - format_action( Prefix, Ai,Ao). - -format_prefix( -Pref) --> "-", !, format_prefix_1(Pref). -format_prefix( +Pref) --> format_prefix_1(Pref). - -format_prefix_1( two(0,N2)) --> ".", !, format_digits(N2). -format_prefix_1( two(N1,N2)) --> format_digits(N1), ".", !, - format_digits(N2). -format_prefix_1( one(N1)) --> format_digits(N1), !. -format_prefix_1( none) --> []. - -format_digits( N) --> [D], - { - D >= "0", - D =< "9", - N0 is D-0'0 - }, - format_digits( N0,N). - -format_digits( N0,N2) --> [D], - { - D >= "0", - D =< "9", - !, - N1 is D-0'0 + N0*10 - }, - format_digits( N1,N2). -format_digits( N0,N0) --> []. - -format_action( Prefix, Ai,Ao) --> [F], - { - format_action_1( F, Prefix, Ai, Ao), ! - }. -format_action( +none, [A|As], As) --> % 0'% without further spec. - { - ( number(A) -> - format( "~5g", [A]) - ; - print(A) - ) - }. - -fmt_norm( rat(N,D), Norm) :- !, ( D=1 -> Norm=N ; Norm is N/D ). -fmt_norm( N, N). - -format_action_1( 0'e, Prefix, [A|As], As) :- fmt_norm( A, An), action_e( Prefix, An). -format_action_1( 0'f, Prefix, [A|As], As) :- fmt_norm( A, An), action_f( Prefix, An). -format_action_1( 0'g, Prefix, [A|As], As) :- fmt_norm( A, An), action_g( Prefix, An). - -format_action_1( 0'%, _, A, A) :- put("%"). - -% -% todo -% -format_action_1( 0'd, Prefix, [A|As], As) :- - fmt_norm( A, An), - Ani is integer(round(An)), - action_d( Prefix, Ani). -format_action_1( 0'o, _Prefix, [A|As], As) :- print(A). -format_action_1( 0'x, _Prefix, [A|As], As) :- print(A). -format_action_1( 0'c, _Prefix, [A|As], As) :- print(A). -format_action_1( 0'u, _Prefix, [A|As], As) :- print(A). -format_action_1( 0's, _Prefix, [A|As], As) :- print(A). - -action_d( +one(A), X) :- format( "~|~t~d~*+", [X,A]). -action_d( +none, X) :- format( "~d", [X]). -action_d( -one(A), X) :- format( "~|~d~t~*+", [X,A]). -action_d( -none, X) :- format( "~d", [X]). - -action_e( +two(A,B), X) :- format( "~|~t~*e~*+", [B,X,A]). -action_e( +one(B), X) :- format( "~|~t~e~*+", [X,B]). -action_e( +none, X) :- format( "~e", [X]). -action_e( -two(A,B), X) :- format( "~|~*e~t~*+", [B,X,A]). -action_e( -one(B), X) :- format( "~|~e~t~*+", [X,B]). -action_e( -none, X) :- format( "~e", [X]). - -action_f( +two(A,B), X) :- format( "~|~t~*f~*+", [B,X,A]). -action_f( +one(B), X) :- format( "~|~t~f~*+", [X,B]). -action_f( +none, X) :- format( "~f", [X]). -action_f( -two(A,B), X) :- format( "~|~*f~t~*+", [B,X,A]). -action_f( -one(B), X) :- format( "~|~f~t~*+", [X,B]). -action_f( -none, X) :- format( "~f", [X]). - -action_g( +two(A,B), X) :- format( "~|~t~*g~*+", [B,X,A]). -action_g( +one(B), X) :- format( "~|~t~g~*+", [X,B]). -action_g( +none, X) :- format( "~g", [X]). -action_g( -two(A,B), X) :- format( "~|~*g~t~*+", [B,X,A]). -action_g( -one(B), X) :- format( "~|~g~t~*+", [X,B]). -action_g( -none, X) :- format( "~g", [X]). - - - - - - - - diff --git a/CLPQR/clpqr/project.pl b/CLPQR/clpqr/project.pl deleted file mode 100644 index 972788fa1..000000000 --- a/CLPQR/clpqr/project.pl +++ /dev/null @@ -1,147 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: project.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% Answer constraint projection -% - -:- public project_attributes/2. % xref.pl - -% -% interface predicate -% -% May be destructive (either acts on a copy or in a failure loop) -% -project_attributes( TargetVars, Cvas) :- - sort( TargetVars, Tvs), % duplicates ? - sort( Cvas, Avs), % duplicates ? - mark_target( Tvs), - project_nonlin( Tvs, Avs, NlReachable), - ( Tvs == [] -> - drop_lin_atts( Avs) - ; - redundancy_vars( Avs), % redundancy.pl - make_target_indep( Tvs, Pivots), - mark_target( NlReachable), % after make_indep to express priority - drop_dep( Avs), - fm_elim( Avs, Tvs, Pivots), - impose_ordering( Avs) - ). - -mark_target( []). -mark_target( [V|Vs]) :- - put_atts( V, target), - mark_target( Vs). - -mark_keep( []). -mark_keep( [V|Vs]) :- - put_atts( V, keep), - mark_keep( Vs). - -% -% Collect the pivots in reverse order -% We have to protect the target variables pivot partners -% from redundancy eliminations triggered by fm_elim, -% in order to allow for reverse pivoting. -% -make_target_indep( Ts, Ps) :- make_target_indep( Ts, [], Ps). - -make_target_indep( [], Ps, Ps). -make_target_indep( [T|Ts], Ps0,Pst) :- - ( get_atts( T, [lin(Lin),type(Type)]), - decompose( Lin, H, _, _), - nontarget( H, Nt) -> - Ps1 = [T:Nt|Ps0], - put_atts( Nt, keep), - pivot( T, Nt, Type) - ; - Ps1 = Ps0 - ), - make_target_indep( Ts, Ps1,Pst). - -nontarget( [V*_|Vs], Nt) :- - ( get_atts( V, [-target,-keep_indep]) -> - Nt = V - ; - nontarget( Vs, Nt) - ). - -drop_dep( Vs) :- var( Vs), !. -drop_dep( []). -drop_dep( [V|Vs]) :- - drop_dep_one( V), - drop_dep( Vs). - -drop_dep_one( V) :- - get_atts( V, [lin(Lin),type(t_none),-target,-keep,-nonzero]), - \+ indep( Lin, V), - !, - put_atts( V, [-lin(_),-type(_),-class(_),-order(_),-strictness(_)]). -drop_dep_one( _). - -drop_lin_atts( []). -drop_lin_atts( [V|Vs]) :- - put_atts( V, [-lin(_),-type(_),-class(_),-order(_),-strictness(_)]), - drop_lin_atts( Vs). - -impose_ordering( Cvas) :- - systems( Cvas, [], Sys), - impose_ordering_sys( Sys). - -impose_ordering_sys( []). -impose_ordering_sys( [S|Ss]) :- - arrangement( S, Arr), % ordering.pl - arrange( Arr, S), - impose_ordering_sys( Ss). - -arrange( [], _). -arrange( Arr, S) :- Arr = [_|_], - class_allvars( S, All), - order( Arr, 1, N), - order( All, N, _), - renorm_all( All), - arrange_pivot( All). - -order( Xs, N, M) :- var(Xs), !, N=M. -order( [], N, N). -order( [X|Xs], N, M) :- - ( get_atts( X, order(O)), - var(O) -> - O=N, - N1 is N+1, - order( Xs, N1, M) - ; - order( Xs, N, M) - ). - -renorm_all( Xs) :- var( Xs), !. -renorm_all( [X|Xs]) :- - ( get_atts( X, lin(Lin)) -> - renormalize( Lin, New), - put_atts( X, lin(New)), - renorm_all( Xs) - ; - renorm_all( Xs) - ). - -arrange_pivot( Xs) :- var( Xs), !. -arrange_pivot( [X|Xs]) :- - ( get_atts( X, [lin(Lin),type(t_none)]), - decompose( Lin, [Y*_|_], _, _), - nf_ordering( Y, X, <) -> - pivot( X, Y, t_none), - arrange_pivot( Xs) - ; - arrange_pivot( Xs) - ). - diff --git a/CLPQR/clpqr/redund.pl b/CLPQR/clpqr/redund.pl deleted file mode 100644 index 1c7c807ec..000000000 --- a/CLPQR/clpqr/redund.pl +++ /dev/null @@ -1,157 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: redund.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% redundancy removal (semantic definition) -% -% done: -% +) deal with active bounds -% +) indep t_[lu] -> t_none invalidates invariants (fixed) -% - -% -% O(n^2), use sort later -% -systems( [], Si, Si). -systems( [V|Vs], Si, So) :- - ( var(V), get_atts( V, class(C)), - not_memq( Si, C) -> - systems( Vs, [C|Si], So) - ; - systems( Vs, Si, So) - ). - -not_memq( [], _). -not_memq( [Y|Ys], X) :- - X \== Y, - not_memq( Ys, X). - -redundancy_systems( []). -redundancy_systems( [S|Sys]) :- - class_allvars( S, All), - redundancy_vs( All), - redundancy_systems( Sys). - -redundancy_vars( Vs) :- !, redundancy_vs( Vs). -redundancy_vars( Vs) :- - statistics( runtime, [Start|_]), - redundancy_vs( Vs), - statistics( runtime, [End|_]), - Duration is End-Start, - format( user_error, "% Redundancy elimination took ~d msec~n", Duration). - - -% -% remove redundant bounds from variables -% -redundancy_vs( Vs) :- var( Vs), !. -redundancy_vs( []). -redundancy_vs( [V|Vs]) :- - ( get_atts( V, [type(Type),strictness(Strict)]), - redundant( Type, V, Strict) -> - redundancy_vs( Vs) - ; - redundancy_vs( Vs) - ). - -redundant( t_l(L), X, Strict) :- - detach_bounds( X), % drop temporarily - negate_l( Strict, L, X), - red_t_l. -redundant( t_u(U), X, Strict) :- - detach_bounds( X), - negate_u( Strict, U, X), - red_t_u. -redundant( t_lu(L,U), X, Strict) :- - strictness_parts( Strict, Sl, Su), - ( put_atts( X, [type(t_u(U)),strictness(Su)]), - negate_l( Strict, L, X) -> - red_t_l, - ( redundant( t_u(U), X, Strict) -> true ; true ) - ; put_atts( X, [type(t_l(L)),strictness(Sl)]), - negate_u( Strict, U, X) -> - red_t_u - ; - true - ). -redundant( t_L(L), X, Strict) :- - arith_eval( -L, Bound), - intro_at( X, Bound, t_none), % drop temporarily - detach_bounds( X), - negate_l( Strict, L, X), - red_t_L. -redundant( t_U(U), X, Strict) :- - arith_eval( -U, Bound), - intro_at( X, Bound, t_none), % drop temporarily - detach_bounds( X), - negate_u( Strict, U, X), - red_t_U. -redundant( t_Lu(L,U), X, Strict) :- - strictness_parts( Strict, Sl, Su), - ( arith_eval( -L, Bound), - intro_at( X, Bound, t_u(U)), - put_atts( X, strictness(Su)), - negate_l( Strict, L, X) -> - red_t_l, - ( redundant( t_u(U), X, Strict) -> true ; true ) - ; put_atts( X, [type(t_L(L)),strictness(Sl)]), - negate_u( Strict, U, X) -> - red_t_u - ; - true - ). -redundant( t_lU(L,U), X, Strict) :- - strictness_parts( Strict, Sl, Su), - ( put_atts( X, [type(t_U(U)),strictness(Su)]), - negate_l( Strict, L, X) -> - red_t_l, - ( redundant( t_U(U), X, Strict) -> true ; true ) - ; arith_eval( -U, Bound), - intro_at( X, Bound, t_l(L)), - put_atts( X, strictness(Sl)), - negate_u( Strict, U, X) -> - red_t_u - ; - true - ). - -strictness_parts( Strict, Lower, Upper) :- - Lower is Strict /\ 2'10, - Upper is Strict /\ 2'01. - -% -% encapsulation via \+ (unfolded to avoid metacall) -% -/**/ -negate_l( 2'00, L, X) :- { L > X }, !, fail. -negate_l( 2'01, L, X) :- { L > X }, !, fail. -negate_l( 2'10, L, X) :- { L >= X }, !, fail. -negate_l( 2'11, L, X) :- { L >= X }, !, fail. -negate_l( _, _, _). - -negate_u( 2'00, U, X) :- { U < X }, !, fail. -negate_u( 2'01, U, X) :- { U =< X }, !, fail. -negate_u( 2'10, U, X) :- { U < X }, !, fail. -negate_u( 2'11, U, X) :- { U =< X }, !, fail. -negate_u( _, _, _). -/**/ - -% -% profiling -% -red_t_l. -red_t_u. -red_t_L. -red_t_U. - - diff --git a/CLPQR/clpqr/store.pl b/CLPQR/clpqr/store.pl deleted file mode 100644 index a87463401..000000000 --- a/CLPQR/clpqr/store.pl +++ /dev/null @@ -1,279 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: store.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% All constants to canonical rep. -% -normalize_scalar( S, [N,Z]) :- - arith_normalize( S, N), - arith_eval( 0, Z). - -renormalize( List, Lin) :- - decompose( List, Hom, R, I), - length( Hom, Len), - renormalize_log( Len, Hom, [], Lin0), - add_linear_11( [I,R], Lin0, Lin). - -renormalize_log( 1, [Term|Xs], Xs, Lin) :- !, - Term = X*_, - renormalize_log_one( X, Term, Lin). -renormalize_log( 2, [A,B|Xs], Xs, Lin) :- !, - A = X*_, - B = Y*_, - renormalize_log_one( X, A, LinA), - renormalize_log_one( Y, B, LinB), - add_linear_11( LinA, LinB, Lin). -renormalize_log( N, L0, L2, Lin) :- - P is N>>1, - Q is N-P, - renormalize_log( P, L0, L1, Lp), - renormalize_log( Q, L1, L2, Lq), - add_linear_11( Lp, Lq, Lin). - -renormalize_log_one( X, Term, Res) :- var(X), - arith_eval( 0, Z), - Res = [Z,Z,Term]. -renormalize_log_one( X, Term, Res) :- nonvar(X), - Term = X*K, - arith_eval( X*K, Xk), - normalize_scalar( Xk, Res). - -% ----------------------------- sparse vector stuff ---------------------------- % - -add_linear_ff( LinA, Ka, LinB, Kb, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia*Ka+Ib*Kb, Ic), - arith_eval( Ra*Ka+Rb*Kb, Rc), - add_linear_ffh( Ha, Ka, Hb, Kb, Hc). - -add_linear_ffh( [], _, Ys, Kb, Zs) :- mult_hom( Ys, Kb, Zs). -add_linear_ffh( [X*Kx|Xs], Ka, Ys, Kb, Zs) :- - add_linear_ffh( Ys, X, Kx, Xs, Zs, Ka, Kb). - - add_linear_ffh( [], X, Kx, Xs, Zs, Ka, _) :- mult_hom( [X*Kx|Xs], Ka, Zs). - add_linear_ffh( [Y*Ky|Ys], X, Kx, Xs, Zs, Ka, Kb) :- - nf_ordering( X, Y, Rel), - ( Rel = =, arith_eval( Kx*Ka+Ky*Kb, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_ffh( Xs, Ka, Ys, Kb, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_ffh( Xs, Ka, Ys, Kb, Ztail) - ) - ; Rel = <, Zs = [X*Kz|Ztail], - arith_eval( Kx*Ka, Kz), - add_linear_ffh( Xs, Y, Ky, Ys, Ztail, Kb, Ka) - ; Rel = >, Zs = [Y*Kz|Ztail], - arith_eval( Ky*Kb, Kz), - add_linear_ffh( Ys, X, Kx, Xs, Ztail, Ka, Kb) - ). - -add_linear_f1( LinA, Ka, LinB, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia*Ka+Ib, Ic), - arith_eval( Ra*Ka+Rb, Rc), - add_linear_f1h( Ha, Ka, Hb, Hc). - -add_linear_f1h( [], _, Ys, Ys). -add_linear_f1h( [X*Kx|Xs], Ka, Ys, Zs) :- - add_linear_f1h( Ys, X, Kx, Xs, Zs, Ka). - - add_linear_f1h( [], X, Kx, Xs, Zs, Ka) :- mult_hom( [X*Kx|Xs], Ka, Zs). - add_linear_f1h( [Y*Ky|Ys], X, Kx, Xs, Zs, Ka) :- - nf_ordering( X, Y, Rel), - ( Rel = =, arith_eval( Kx*Ka+Ky, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_f1h( Xs, Ka, Ys, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_f1h( Xs, Ka, Ys, Ztail) - ) - ; Rel = <, Zs = [X*Kz|Ztail], - arith_eval( Kx*Ka, Kz), - add_linear_f1h( Xs, Ka, [Y*Ky|Ys], Ztail) - ; Rel = >, Zs = [Y*Ky|Ztail], - add_linear_f1h( Ys, X, Kx, Xs, Ztail, Ka) - ). - -add_linear_11( LinA, LinB, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia+Ib, Ic), - arith_eval( Ra+Rb, Rc), - add_linear_11h( Ha, Hb, Hc). - -add_linear_11h( [], Ys, Ys). -add_linear_11h( [X*Kx|Xs], Ys, Zs) :- - add_linear_11h( Ys, X, Kx, Xs, Zs). - - add_linear_11h( [], X, Kx, Xs, [X*Kx|Xs]). - add_linear_11h( [Y*Ky|Ys], X, Kx, Xs, Zs) :- - nf_ordering( X, Y, Rel), - ( Rel = =, arith_eval( Kx+Ky, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_11h( Xs, Ys, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_11h( Xs, Ys, Ztail) - ) - ; Rel = <, Zs = [X*Kx|Ztail], add_linear_11h( Xs, Y, Ky, Ys, Ztail) - ; Rel = >, Zs = [Y*Ky|Ztail], add_linear_11h( Ys, X, Kx, Xs, Ztail) - ). - -mult_linear_factor( Lin, K, Mult) :- - arith_eval( K=:=1 ), % avoid copy - !, - Mult = Lin. -mult_linear_factor( Lin, K, Res) :- - decompose( Lin, Hom, R, I), - decompose( Res, Mult, Rk, Ik), - arith_eval( I*K, Ik), - arith_eval( R*K, Rk), - mult_hom( Hom, K, Mult). - -mult_hom( [], _, []). -mult_hom( [A*Fa|As], F, [A*Fan|Afs]) :- - arith_eval( F*Fa, Fan), - mult_hom( As, F, Afs). - -/* -% -% slightly stabilizes clp(r) numerically -% -mult_hom( [], _, []). -mult_hom( [X*Kx|Xs], K, Res) :- - arith_eval( K*Kx, C), - ( arith_eval( C=:=0) -> - mult_hom( Xs, K, Res) - ; - Res = [X*C|Tail], - mult_hom( Xs, K, Tail) - ). -*/ - -% -% Replace V in H by its new definition, Vh+Vi -% -nf_substitute( V, LinV, LinX, LinX1) :- - delete_factor( V, LinX, LinW, K), - add_linear_f1( LinV, K, LinW, LinX1). - - -delete_factor( Vid, Lin, Res, Coeff) :- - decompose( Lin, Hom, R, I), - decompose( Res, Hdel, R, I), - delete_factor_hom( Vid, Hom, Hdel, Coeff). -/**/ -% -% Makes no use of the nf_ordering and is faster ... -% Depends of course on the price of nf_ordering/3 -% -delete_factor_hom( Vid, [Car|Cdr], RCdr, RKoeff) :- - Car = Var*Koeff, - compare( R, Var, Vid), - ( R = =, RCdr = Cdr, RKoeff=Koeff - ; R = <, RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ; R = >, RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ). -/**/ -/** -% -% -% -delete_factor_hom( Vid, [Car|Cdr], RCdr, RKoeff) :- - Car = Var*Koeff, - nf_ordering( Vid, Var, Rel), - ( Rel= =, - RCdr = Cdr, RKoeff=Koeff - ; Rel= >, - RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ). -**/ - - -% nf_coeff_of( Nf, X, Coeff) -% determine the coeff of variable X in Nf -% fails if X is not a member of the Nf -% -nf_coeff_of( Lin, Vid, Coeff) :- - decompose( Lin, Hom, _, _), - get_atts( Vid, order(OVid)), % pulled out of loop - nf_coeff_hom( Hom, OVid, Coeff), !. - -nf_coeff_hom( [Var*K|Vs], Vid, Coeff) :- - % nf_ordering( Vid, Var, Rel), - get_atts( Var, order(OVar)), - compare( Rel, Vid, OVar), - ( Rel= =, Coeff = K - ; Rel= >, nf_coeff_hom( Vs, Vid, Coeff) - ). - -nf_rhs_x( Lin, X, Rhs,K) :- - decompose( Lin, Tail, R, I), - get_atts( X, order(Ox)), % pulled out of loop - nf_coeff_hom( Tail, Ox, K), - arith_eval( R+I, Rhs). % late because X may not occur in H - -% -% solve for New = Lin1 -% -isolate( New, Lin, Lin1) :- - delete_factor( New, Lin, Lin0, Coeff), - arith_eval( -1/Coeff, K), - mult_linear_factor( Lin0, K, Lin1). - - -indep( Lin, X) :- - decompose( Lin, [Y*K], _, I), - X == Y, - arith_eval( K=:=1), - arith_eval( I=:=0). - -nf2sum( [], I, I). -nf2sum( [X|Xs], I, Sum) :- - ( arith_eval(I=:=0) -> - X = Var*K, - ( arith_eval( K=:=1) -> - hom2sum( Xs, Var, Sum) - ; arith_eval( K=:= -1) -> - hom2sum( Xs, -Var, Sum) - ; - hom2sum( Xs, K*Var, Sum) - ) - ; - hom2sum( [X|Xs], I, Sum) - ). - -hom2sum( [], Term, Term). -hom2sum( [Var*K|Cs], Sofar, Term) :- - ( arith_eval( K=:=1) -> - Next = Sofar + Var - ; arith_eval( K=:= -1) -> - Next = Sofar - Var - ; arith_eval( K < 0) -> - arith_eval( -K, Ka), - Next = Sofar - Ka*Var - ; - Next = Sofar + K*Var - ), - hom2sum( Cs, Next, Term). - - diff --git a/CLPQR/clpqr/store.yap b/CLPQR/clpqr/store.yap deleted file mode 100644 index 517dfc8f9..000000000 --- a/CLPQR/clpqr/store.yap +++ /dev/null @@ -1,282 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: store.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% All constants to canonical rep. -% -normalize_scalar( S, [N,Z]) :- - arith_normalize( S, N), - arith_eval( 0, Z). - -renormalize( List, Lin) :- - decompose( List, Hom, R, I), - length( Hom, Len), - renormalize_log( Len, Hom, [], Lin0), - add_linear_11( [I,R], Lin0, Lin). - -renormalize_log( 1, [Term|Xs], Xs, Lin) :- !, - Term = X*_, - renormalize_log_one( X, Term, Lin). -renormalize_log( 2, [A,B|Xs], Xs, Lin) :- !, - A = X*_, - B = Y*_, - renormalize_log_one( X, A, LinA), - renormalize_log_one( Y, B, LinB), - add_linear_11( LinA, LinB, Lin). -renormalize_log( N, L0, L2, Lin) :- - P is N>>1, - Q is N-P, - renormalize_log( P, L0, L1, Lp), - renormalize_log( Q, L1, L2, Lq), - add_linear_11( Lp, Lq, Lin). - -renormalize_log_one( X, Term, Res) :- var(X), - arith_eval( 0, Z), - Res = [Z,Z,Term]. -renormalize_log_one( X, Term, Res) :- nonvar(X), - Term = X*K, - arith_eval( X*K, Xk), - normalize_scalar( Xk, Res). - -% ----------------------------- sparse vector stuff ---------------------------- % - -add_linear_ff( LinA, Ka, LinB, Kb, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia*Ka+Ib*Kb, Ic), - arith_eval( Ra*Ka+Rb*Kb, Rc), - add_linear_ffh( Ha, Ka, Hb, Kb, Hc). - -add_linear_ffh( [], _, Ys, Kb, Zs) :- mult_hom( Ys, Kb, Zs). -add_linear_ffh( [X*Kx|Xs], Ka, Ys, Kb, Zs) :- - add_linear_ffh( Ys, X, Kx, Xs, Zs, Ka, Kb). - - add_linear_ffh( [], X, Kx, Xs, Zs, Ka, _) :- mult_hom( [X*Kx|Xs], Ka, Zs). - add_linear_ffh( [Y*Ky|Ys], X, Kx, Xs, Zs, Ka, Kb) :- - nf_ordering( X, Y, Rel), - %vsc: added -> (01/06/06) - ( Rel = = -> arith_eval( Kx*Ka+Ky*Kb, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_ffh( Xs, Ka, Ys, Kb, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_ffh( Xs, Ka, Ys, Kb, Ztail) - ) - ; Rel = < -> Zs = [X*Kz|Ztail], - arith_eval( Kx*Ka, Kz), - add_linear_ffh( Xs, Y, Ky, Ys, Ztail, Kb, Ka) - ; Rel = > -> Zs = [Y*Kz|Ztail], - arith_eval( Ky*Kb, Kz), - add_linear_ffh( Ys, X, Kx, Xs, Ztail, Ka, Kb) - ). - -add_linear_f1( LinA, Ka, LinB, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia*Ka+Ib, Ic), - arith_eval( Ra*Ka+Rb, Rc), - add_linear_f1h( Ha, Ka, Hb, Hc). - -add_linear_f1h( [], _, Ys, Ys). -add_linear_f1h( [X*Kx|Xs], Ka, Ys, Zs) :- - add_linear_f1h( Ys, X, Kx, Xs, Zs, Ka). - - add_linear_f1h( [], X, Kx, Xs, Zs, Ka) :- mult_hom( [X*Kx|Xs], Ka, Zs). - add_linear_f1h( [Y*Ky|Ys], X, Kx, Xs, Zs, Ka) :- - nf_ordering( X, Y, Rel), - %vsc: added -> (01/06/06) - ( Rel = = -> arith_eval( Kx*Ka+Ky, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_f1h( Xs, Ka, Ys, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_f1h( Xs, Ka, Ys, Ztail) - ) - ; Rel = < -> Zs = [X*Kz|Ztail], - arith_eval( Kx*Ka, Kz), - add_linear_f1h( Xs, Ka, [Y*Ky|Ys], Ztail) - ; Rel = > -> Zs = [Y*Ky|Ztail], - add_linear_f1h( Ys, X, Kx, Xs, Ztail, Ka) - ). - -add_linear_11( LinA, LinB, LinC) :- - decompose( LinA, Ha, Ra, Ia), - decompose( LinB, Hb, Rb, Ib), - decompose( LinC, Hc, Rc, Ic), - arith_eval( Ia+Ib, Ic), - arith_eval( Ra+Rb, Rc), - add_linear_11h( Ha, Hb, Hc). - -add_linear_11h( [], Ys, Ys). -add_linear_11h( [X*Kx|Xs], Ys, Zs) :- - add_linear_11h( Ys, X, Kx, Xs, Zs). - - add_linear_11h( [], X, Kx, Xs, [X*Kx|Xs]). - add_linear_11h( [Y*Ky|Ys], X, Kx, Xs, Zs) :- - nf_ordering( X, Y, Rel), - %vsc: added -> (01/06/06) - ( Rel = = -> arith_eval( Kx+Ky, Kz), - ( arith_eval(Kz=:=0) -> - add_linear_11h( Xs, Ys, Zs) - ; - Zs = [X*Kz|Ztail], - add_linear_11h( Xs, Ys, Ztail) - ) - ; Rel = < -> Zs = [X*Kx|Ztail], add_linear_11h( Xs, Y, Ky, Ys, Ztail) - ; Rel = > -> Zs = [Y*Ky|Ztail], add_linear_11h( Ys, X, Kx, Xs, Ztail) - ). - -mult_linear_factor( Lin, K, Mult) :- - arith_eval( K=:=1 ), % avoid copy - !, - Mult = Lin. -mult_linear_factor( Lin, K, Res) :- - decompose( Lin, Hom, R, I), - decompose( Res, Mult, Rk, Ik), - arith_eval( I*K, Ik), - arith_eval( R*K, Rk), - mult_hom( Hom, K, Mult). - -mult_hom( [], _, []). -mult_hom( [A*Fa|As], F, [A*Fan|Afs]) :- - arith_eval( F*Fa, Fan), - mult_hom( As, F, Afs). - -/* -% -% slightly stabilizes clp(r) numerically -% -mult_hom( [], _, []). -mult_hom( [X*Kx|Xs], K, Res) :- - arith_eval( K*Kx, C), - ( arith_eval( C=:=0) -> - mult_hom( Xs, K, Res) - ; - Res = [X*C|Tail], - mult_hom( Xs, K, Tail) - ). -*/ - -% -% Replace V in H by its new definition, Vh+Vi -% -nf_substitute( V, LinV, LinX, LinX1) :- - delete_factor( V, LinX, LinW, K), - add_linear_f1( LinV, K, LinW, LinX1). - - -delete_factor( Vid, Lin, Res, Coeff) :- - decompose( Lin, Hom, R, I), - decompose( Res, Hdel, R, I), - delete_factor_hom( Vid, Hom, Hdel, Coeff). -/**/ -% -% Makes no use of the nf_ordering and is faster ... -% Depends of course on the price of nf_ordering/3 -% -delete_factor_hom( Vid, [Car|Cdr], RCdr, RKoeff) :- - Car = Var*Koeff, - compare( R, Var, Vid), - ( R = = -> RCdr = Cdr, RKoeff=Koeff %vsc: added -> (01/06/06) - ; R = < -> RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ; R = > -> RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ). -/**/ -/** -% -% -% -delete_factor_hom( Vid, [Car|Cdr], RCdr, RKoeff) :- - Car = Var*Koeff, - nf_ordering( Vid, Var, Rel), - ( Rel= =, - RCdr = Cdr, RKoeff=Koeff - ; Rel= >, - RCdr = [Car|RCdr1], - delete_factor_hom( Vid, Cdr, RCdr1, RKoeff) - ). -**/ - - -% nf_coeff_of( Nf, X, Coeff) -% determine the coeff of variable X in Nf -% fails if X is not a member of the Nf -% -nf_coeff_of( Lin, Vid, Coeff) :- - decompose( Lin, Hom, _, _), - get_atts( Vid, order(OVid)), % pulled out of loop - nf_coeff_hom( Hom, OVid, Coeff), !. - -nf_coeff_hom( [Var*K|Vs], Vid, Coeff) :- - % nf_ordering( Vid, Var, Rel), - get_atts( Var, order(OVar)), - compare( Rel, Vid, OVar), - ( Rel= =, Coeff = K - ; Rel= >, nf_coeff_hom( Vs, Vid, Coeff) - ). - -nf_rhs_x( Lin, X, Rhs,K) :- - decompose( Lin, Tail, R, I), - get_atts( X, order(Ox)), % pulled out of loop - nf_coeff_hom( Tail, Ox, K), - arith_eval( R+I, Rhs). % late because X may not occur in H - -% -% solve for New = Lin1 -% -isolate( New, Lin, Lin1) :- - delete_factor( New, Lin, Lin0, Coeff), - arith_eval( -1/Coeff, K), - mult_linear_factor( Lin0, K, Lin1). - - -indep( Lin, X) :- - decompose( Lin, [Y*K], _, I), - X == Y, - arith_eval( K=:=1), - arith_eval( I=:=0). - -nf2sum( [], I, I). -nf2sum( [X|Xs], I, Sum) :- - ( arith_eval(I=:=0) -> - X = Var*K, - ( arith_eval( K=:=1) -> - hom2sum( Xs, Var, Sum) - ; arith_eval( K=:= -1) -> - hom2sum( Xs, -Var, Sum) - ; - hom2sum( Xs, K*Var, Sum) - ) - ; - hom2sum( [X|Xs], I, Sum) - ). - -hom2sum( [], Term, Term). -hom2sum( [Var*K|Cs], Sofar, Term) :- - ( arith_eval( K=:=1) -> - Next = Sofar + Var - ; arith_eval( K=:= -1) -> - Next = Sofar - Var - ; arith_eval( K < 0) -> - arith_eval( -K, Ka), - Next = Sofar - Ka*Var - ; - Next = Sofar + K*Var - ), - hom2sum( Cs, Next, Term). - - diff --git a/CLPQR/clpr.pl b/CLPQR/clpr.pl deleted file mode 100644 index 83e815035..000000000 --- a/CLPQR/clpr.pl +++ /dev/null @@ -1,61 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: clpr.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- module( clpr, [ - {}/1, - maximize/1, - minimize/1, - inf/2, inf/4, sup/2, sup/4, - bb_inf/3, - bb_inf/5, - ordering/1, - entailed/1, - dump/3 - ]). - -% -% Don't report export of private predicates from clpr -% -:- multifile - user:portray_message/2. - -:- dynamic - user:portray_message/2. -% -user:portray_message( warning, import(_,_,clpr,private)). - -this_linear_solver( clpr). - -:- use_module( 'clpr/arith_r'). - -:- ensure_loaded( - [ - 'clpr/itf3', - 'clpr/store' % early because of macros - % but after itf3 - ]). - -:- use_module( 'clpr/geler'). -:- use_module( 'clpr/nfr'). -:- use_module( 'clpr/class'). - -:- ensure_loaded( - [ - 'clpr/project', - 'clpr/bv', - 'clpr/ineq', - 'clpr/redund', - 'clpr/fourmotz', - 'clpr/bb', - 'clpr/dump' - ]). - diff --git a/CLPQR/clpr.yap b/CLPQR/clpr.yap deleted file mode 100644 index 128e98255..000000000 --- a/CLPQR/clpr.yap +++ /dev/null @@ -1,64 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: clpr.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% :- sequential. - -% :- default_sequential(X), write(X), nl. - -:- module( clpr, [ - {}/1, - maximize/1, - minimize/1, - inf/2, inf/4, sup/2, sup/4, - bb_inf/3, - bb_inf/5, - ordering/1, - entailed/1, - dump/3 - ]). - -% -% Don't report export of private predicates from clpr -% -:- multifile - user:portray_message/2. - -:- dynamic - user:portray_message/2. -% -user:portray_message( warning, import(_,_,clpr,private)). - -this_linear_solver( clpr). - -:- use_module( 'clpr/arith_r'). - -:- ensure_loaded( - [ - 'clpqr/itf3', - 'clpqr/store' % early because of macros - % but after itf3 - ]). - -:- use_module( 'clpr/geler'). -:- use_module( 'clpr/nfr'). -:- use_module( 'clpr/class'). - -:- ensure_loaded( - [ - 'clpqr/project', - 'clpqr/bv', - 'clpqr/ineq', - 'clpqr/redund', - 'clpqr/fourmotz', - 'clpqr/bb', - 'clpqr/dump' - ]). diff --git a/CLPQR/clpr/arith_r.pl b/CLPQR/clpr/arith_r.pl deleted file mode 100644 index 12790d408..000000000 --- a/CLPQR/clpr/arith_r.pl +++ /dev/null @@ -1,69 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: arith_r.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( arith_r, - [ - arith_eps/1, - arith_normalize/2, - integerp/1, - integerp/2 - ]). - -% -% Modules receiving R expansion -% -arith_module( clpr). -arith_module( nfr). - -:- multifile - user:goal_expansion/3. - -:- dynamic - user:goal_expansion/3. -% - -user:goal_expansion(arith_eval(Term,Res), Module, Expansion) :- - arith_module( Module), - compile_R( Term, Res, Code), - l2conj( Code, Expansion). - -user:goal_expansion(arith_eval(Rel), Module, Expansion) :- - arith_module( Module), - compile_R( Rel, boolean, Code), - l2conj( Code, Expansion). - -user:goal_expansion(case_signum(Term,Lt,Z,Gt), Module, Expansion) :- - arith_module( Module), - compile_case_signum_R( Term, Lt,Z,Gt, Code), - l2conj( Code, Expansion). - -:- ensure_loaded( arith). - -% -% This the only place where this constant lives -% -arith_eps( 1.0e-10). % for Monash #zero expansion 1.0e-12 -eps( 1.0e-10, -1.0e-10). - -arith_normalize( X, Norm) :- var(X), !, - raise_exception( instantiation_error(arith_normalize(X,Norm),1)). -arith_normalize( rat(N,D), Norm) :- rat_float( N,D, Norm). -arith_normalize( X, Norm) :- number(X), - Norm is float(X). - -integerp( X) :- - floor(/*float?*/X)=:=X. - -integerp( X, I) :- - floor(/*float?*/X)=:=X, - I is integer(X). diff --git a/CLPQR/clpr/arith_r.yap b/CLPQR/clpr/arith_r.yap deleted file mode 100644 index 2a061ecc4..000000000 --- a/CLPQR/clpr/arith_r.yap +++ /dev/null @@ -1,69 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: arith_r.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( arith_r, - [ - arith_eps/1, - arith_normalize/2, - integerp/1, - integerp/2 - ]). - -% -% Modules receiving R expansion -% -arith_module( clpr). -arith_module( nfr). - -:- multifile - user:goal_expansion/3. - -:- dynamic - user:goal_expansion/3. -% - -user:goal_expansion(arith_eval(Term,Res), Module, Expansion) :- - arith_module( Module), - compile_R( Term, Res, Code), - l2conj( Code, Expansion). - -user:goal_expansion(arith_eval(Rel), Module, Expansion) :- - arith_module( Module), - compile_R( Rel, boolean, Code), - l2conj( Code, Expansion). - -user:goal_expansion(case_signum(Term,Lt,Z,Gt), Module, Expansion) :- - arith_module( Module), - compile_case_signum_R( Term, Lt,Z,Gt, Code), - l2conj( Code, Expansion). - -:- ensure_loaded( '../clpqr/arith'). - -% -% This the only place where this constant lives -% -arith_eps( 1.0e-10). % for Monash #zero expansion 1.0e-12 -eps( 1.0e-10, -1.0e-10). - -arith_normalize( X, Norm) :- var(X), !, - raise_exception( instantiation_error(arith_normalize(X,Norm),1)). -arith_normalize( rat(N,D), Norm) :- rat_float( N,D, Norm). -arith_normalize( X, Norm) :- number(X), - Norm is float(X). - -integerp( X) :- - floor(/*float?*/X)=:=X. - -integerp( X, I) :- - floor(/*float?*/X)=:=X, - I is integer(X). diff --git a/CLPQR/clpr/class.pl b/CLPQR/clpr/class.pl deleted file mode 100644 index 29134eb7f..000000000 --- a/CLPQR/clpr/class.pl +++ /dev/null @@ -1,113 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: class.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% the class theory -% - -:- module( classr, - [ - class_allvars/2, - class_new/4, - class_drop/2, - class_basis/2, - class_basis_add/3, - class_basis_drop/2, - class_basis_pivot/3, - - ordering/1, - arrangement/2 - ]). - -:- use_module( clpr, '../clpr', [get_or_add_class/2]). - -:- ensure_loaded( ordering). - -:- use_module( library(lists), [append/3]). - -:- use_module( library(atts)). - -:- attribute class_atts/4. - - -verify_attributes( X, Y, []) :- - get_atts( X, class_atts(La,Lat,ABasis,PrioA)), - !, - var( Y), % required - get_atts( Y, class_atts(Lb,Lbt,BBasis,PrioB)), - Lat = Lb, % append - append( ABasis, BBasis, CBasis), - combine( PrioA, PrioB, PrioC), - put_atts( Y, class_atts(La,Lbt,CBasis,PrioC)). -verify_attributes( _, _, []). - -% -% for the debugger -% -% attribute_goal( V, V:A) :- get_atts( V, A), A = [_|_]. - - -% ---------------------------------------------------------------------------------- - -class_new( Class, All,AllT, Basis) :- - put_atts( Su, class_atts(All,AllT,Basis,[])), - Su = Class. - -class_get_prio( Class, Priority) :- - get_atts( Class, class_atts(_,_,_,Priority)). - -class_put_prio( Class, Priority) :- - get_atts( Class, class_atts(All,AllT,Basis,_)), - put_atts( Class, class_atts(All,AllT,Basis,Priority)). - -class_drop( Class, X) :- - get_atts( Class, class_atts(Allvars,Tail,Basis,Priority)), - delete_first( Allvars, X, NewAllvars), - delete_first( Basis, X, NewBasis), - put_atts( Class, class_atts(NewAllvars,Tail,NewBasis,Priority)). - -class_allvars( Class, All) :- get_atts( Class, class_atts(All,_,_,_)). - -class_basis( Class, Basis) :- get_atts( Class, class_atts(_,_,Basis,_)). - -class_basis_add( Class, X, NewBasis) :- - NewBasis = [X|Basis], - get_atts( Class, class_atts(All,AllT,Basis,Priority)), - put_atts( Class, class_atts(All,AllT,NewBasis,Priority)). - -class_basis_drop( Class, X) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, X, Basis), - Basis0 \== Basis, % anything deleted ? - !, - put_atts( Class, class_atts(All,AllT,Basis,Priority)). -class_basis_drop( _, _). - -class_basis_pivot( Class, Enter, Leave) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, Leave, Basis1), - put_atts( Class, class_atts(All,AllT,[Enter|Basis1],Priority)). - -% -% remove the first occurence -% -delete_first( L, _, Res) :- var(L), !, Res = L. -delete_first( [], _, []). -delete_first( [Y|Ys], X, Res) :- - ( X==Y -> - Res = Ys - ; - Res = [Y|Tail], - delete_first( Ys, X, Tail) - ). - diff --git a/CLPQR/clpr/class.yap b/CLPQR/clpr/class.yap deleted file mode 100644 index d7d2c624c..000000000 --- a/CLPQR/clpr/class.yap +++ /dev/null @@ -1,114 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.2 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: class.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -% -% the class theory -% - -:- module( classr, - [ - class_allvars/2, - class_new/4, - class_drop/2, - class_basis/2, - class_basis_add/3, - class_basis_drop/2, - class_basis_pivot/3, - - ordering/1, - arrangement/2 - ]). - - -:- use_module( clpr, '../clpr', [get_or_add_class/2]). - -:- ensure_loaded( '../clpqr/ordering'). - -:- use_module( library(lists), [append/3]). - -:- use_module( library(atts)). - -:- attribute class_atts/4. - - -verify_attributes( X, Y, []) :- - get_atts( X, class_atts(La,Lat,ABasis,PrioA)), - !, - var( Y), % required - get_atts( Y, class_atts(Lb,Lbt,BBasis,PrioB)), - Lat = Lb, % append - append( ABasis, BBasis, CBasis), - combine( PrioA, PrioB, PrioC), - put_atts( Y, class_atts(La,Lbt,CBasis,PrioC)). -verify_attributes( _, _, []). - -% -% for the debugger -% -% attribute_goal( V, V:A) :- get_atts( V, A), A = [_|_]. - - -% ---------------------------------------------------------------------------------- - -class_new( Class, All,AllT, Basis) :- - put_atts( Su, class_atts(All,AllT,Basis,[])), - Su = Class. - -class_get_prio( Class, Priority) :- - get_atts( Class, class_atts(_,_,_,Priority)). - -class_put_prio( Class, Priority) :- - get_atts( Class, class_atts(All,AllT,Basis,_)), - put_atts( Class, class_atts(All,AllT,Basis,Priority)). - -class_drop( Class, X) :- - get_atts( Class, class_atts(Allvars,Tail,Basis,Priority)), - delete_first( Allvars, X, NewAllvars), - delete_first( Basis, X, NewBasis), - put_atts( Class, class_atts(NewAllvars,Tail,NewBasis,Priority)). - -class_allvars( Class, All) :- get_atts( Class, class_atts(All,_,_,_)). - -class_basis( Class, Basis) :- get_atts( Class, class_atts(_,_,Basis,_)). - -class_basis_add( Class, X, NewBasis) :- - NewBasis = [X|Basis], - get_atts( Class, class_atts(All,AllT,Basis,Priority)), - put_atts( Class, class_atts(All,AllT,NewBasis,Priority)). - -class_basis_drop( Class, X) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, X, Basis), - Basis0 \== Basis, % anything deleted ? - !, - put_atts( Class, class_atts(All,AllT,Basis,Priority)). -class_basis_drop( _, _). - -class_basis_pivot( Class, Enter, Leave) :- - get_atts( Class, class_atts(All,AllT,Basis0,Priority)), - delete_first( Basis0, Leave, Basis1), - put_atts( Class, class_atts(All,AllT,[Enter|Basis1],Priority)). - -% -% remove the first occurence -% -delete_first( L, _, Res) :- var(L), !, Res = L. -delete_first( [], _, []). -delete_first( [Y|Ys], X, Res) :- - ( X==Y -> - Res = Ys - ; - Res = [Y|Tail], - delete_first( Ys, X, Tail) - ). - diff --git a/CLPQR/clpr/geler.pl b/CLPQR/clpr/geler.pl deleted file mode 100644 index ccece1af8..000000000 --- a/CLPQR/clpr/geler.pl +++ /dev/null @@ -1,124 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: geler.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( geler_r, - [ - geler/2, - project_nonlin/3, - collect_nonlin/3 - ]). - -:- use_module( library(atts)). - -:- attribute goals/1, all_nonlin/1. - -attribute_goal( X, Goals) :- - get_atts( X, goals(Gs)), - nonexhausted( Gs, Goals, []), - Goals = [_|_]. -attribute_goal( X, Conj) :- - get_atts( X, all_nonlin(Goals)), - l2conj( Goals, Conj). - -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - -nonexhausted( run(Mutex,G)) --> - ( { - var(Mutex) - } -> - [ G ] - ; - [] - ). -nonexhausted( (A,B)) --> - nonexhausted( A), - nonexhausted( B). - -verify_attributes( X, Y, Later) :- - get_atts( X, goals(Gx)), - !, - ( var(Y), - ( get_atts( Y, goals(Gy)) -> - Later = [Gx,Gy], - put_atts( Y, -goals(_)) - ; - Later = [], - put_atts( Y, goals(Gx)) - ) - ; nonvar( Y), - Later = [Gx] - ). -verify_attributes( _, _, []). - -/* -project_attributes( _, Cvas) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - put_atts( _, all_nonlin(Ls)). -*/ - -% -% called from project.pl -% -project_nonlin( _, Cvas, Reachable) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - prolog:term_variables( Ls, Reachable), - put_atts( _, all_nonlin(Ls)). - -collect_nonlin( []) --> []. -collect_nonlin( [X|Xs]) --> - ( {get_atts( X, goals(Gx))} -> - trans( Gx), - collect_nonlin( Xs) - ; - collect_nonlin( Xs) - ). - -trans( (A,B)) --> - trans( A), - trans( B). -trans( run(Mutex,Gs)) --> - ( {var(Mutex)} -> - {Mutex = done}, - transg( Gs) - ; - [] - ). - -transg( (A,B)) --> !, - transg( A), - transg( B). -transg( M:G) --> !, - M:transg( G). -transg( G) --> [ G ]. - -run( Mutex, _) :- nonvar(Mutex). -run( Mutex, G) :- var(Mutex), Mutex=done, call( G). - -:- meta_predicate geler(+,:). -% -geler( Vars, Goal) :- - attach( Vars, run(_Mutex,Goal)). - -attach( [], _). -attach( [V|Vs], Goal) :- - ( var(V), get_atts( V, goals(Gv)) -> - put_atts( V, goals((Goal,Gv))) - ; - put_atts( V, goals(Goal)) - ), - attach( Vs, Goal). diff --git a/CLPQR/clpr/geler.yap b/CLPQR/clpr/geler.yap deleted file mode 100644 index a0143168b..000000000 --- a/CLPQR/clpr/geler.yap +++ /dev/null @@ -1,128 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: geler.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( geler_r, - [ - geler/2, - project_nonlin/3, - collect_nonlin/3 - ]). - -:- use_module( library(atts)). - -:- use_module( library(terms)). - -:- attribute goals/1, all_nonlin/1. - -attribute_goal( X, Goals) :- - get_atts( X, goals(Gs)), - nonexhausted( Gs, Goals, []), - Goals = [_|_]. -attribute_goal( X, Conj) :- - get_atts( X, all_nonlin(Goals)), - l2conj( Goals, Conj). - -l2conj( [X|Xs], Conj) :- - ( Xs = [], Conj = X - ; Xs = [_|_], Conj = (X,Xc), l2conj( Xs, Xc) - ). - -nonexhausted( run(Mutex,G)) --> - ( { - var(Mutex) - } -> - [ G ] - ; - [] - ). -nonexhausted( (A,B)) --> - nonexhausted( A), - nonexhausted( B). - -verify_attributes( X, Y, Later) :- - get_atts( X, goals(Gx)), - !, - ( var(Y), - ( get_atts( Y, goals(Gy)) -> - Later = [Gx,Gy], - put_atts( Y, -goals(_)) - ; - Later = [], - put_atts( Y, goals(Gx)) - ) - ; nonvar( Y), - Later = [Gx] - ). -verify_attributes( _, _, []). - -/* -project_attributes( _, Cvas) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - put_atts( _, all_nonlin(Ls)). -*/ - -% -% called from project.pl -% -project_nonlin( _, Cvas, Reachable) :- - collect_nonlin( Cvas, L, []), - sort( L, Ls), - term_variables( Ls, Reachable), % vsc - put_atts( _, all_nonlin(Ls)). - -collect_nonlin( []) --> []. -collect_nonlin( [X|Xs]) --> - ( {get_atts( X, goals(Gx))} -> - trans( Gx), - collect_nonlin( Xs) - ; - collect_nonlin( Xs) - ). - -trans( (A,B)) --> - trans( A), - trans( B). -trans( run(Mutex,Gs)) --> - ( {var(Mutex)} -> - {Mutex = done}, - transg( Gs) - ; - [] - ). - -transg( (A,B)) --> !, - transg( A), - transg( B). -transg( M:G) --> !, - M:transg( G). -transg( G) --> [ G ]. - -%vsc: added ! (01/06/06) -run( Mutex, _) :- nonvar(Mutex), !. -run( Mutex, G) :- var(Mutex), Mutex=done, call( G). - -:- meta_predicate geler(+,:). -% - -geler( Vars, Goal) :- - attach( Vars, run(_Mutex,Goal)). - -attach( [], _). -attach( [V|Vs], Goal) :- - ( var(V), get_atts( V, goals(Gv)) -> - put_atts( V, goals((Goal,Gv))) - ; - put_atts( V, goals(Goal)) - ), - attach( Vs, Goal). diff --git a/CLPQR/clpr/nf.yap b/CLPQR/clpr/nf.yap deleted file mode 100644 index 7fddea7fd..000000000 --- a/CLPQR/clpr/nf.yap +++ /dev/null @@ -1,835 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nf.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- use_module( library(terms), [term_variables/2]). -:- use_module( geler). - -% ------------------------------------------------------------------------- - -{ Rel } :- var( Rel), !, raise_exception(instantiation_error({Rel},1)). -{ R,Rs } :- !, {R}, {Rs}. -{ R;Rs } :- !, ({R} ; {Rs}). % for entailment checking -{ L < R } :- !, nf( L-R, Nf), submit_lt( Nf). -{ L > R } :- !, nf( R-L, Nf), submit_lt( Nf). -{ L =< R } :- !, nf( L-R, Nf), submit_le( Nf). -{ <=(L,R) } :- !, nf( L-R, Nf), submit_le( Nf). -{ L >= R } :- !, nf( R-L, Nf), submit_le( Nf). -{ L =\= R } :- !, nf( L-R, Nf), submit_ne( Nf). -{ L =:= R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ L = R } :- !, nf( L-R, Nf), submit_eq( Nf). -{ Rel } :- raise_exception( type_error({Rel},1,'a constraint',Rel)). - -% -% s -> c = ~s v c = ~(s /\ ~c) -% where s is the store and c is the constraint for which -% we want to know whether it is entailed. -% -entailed( C) :- - negate( C, Cn), - \+ { Cn }. - -negate( Rel, _) :- var( Rel), !, raise_exception(instantiation_error(entailed(Rel),1)). -negate( (A,B), (Na;Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( (A;B), (Na,Nb)) :- !, negate( A, Na), negate( B, Nb). -negate( A=B) :- !. -negate( A>B, A=B) :- !. -negate( A>=B, A A=0 - b4) nonlinear -> geler - c) Nf=[A,B|Rest] - c1) A=k - c11) B=X^+-1, Rest=[] -> B= - c12) invertible(A,B) - c13) linear(B|Rest) - c14) geler - c2) linear(Nf) - c3) nonlinear -> geler -*/ -submit_eq( []). % trivial success -submit_eq( [T|Ts]) :- - submit_eq( Ts, T). - -submit_eq( [], A) :- submit_eq_b( A). -submit_eq( [B|Bs], A) :- submit_eq_c( A, B, Bs). - -submit_eq_b( v(_,[])) :- !, fail. % b1: trivial failure -submit_eq_b( v(_,[X^P])) :- % b2,b3: n*x^p=0 -> x=0 - var( X), - P > 0, - !, - arith_eval( 0, Z), - export_binding( X, Z). -submit_eq_b( v(_,[NL^1])) :- % b2 - nonvar( NL), - arith_eval( 0, Z), - nl_invertible( NL, X, Z, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_b( Term) :- % b4 - term_variables( Term, Vs), - geler( Vs, resubmit_eq([Term])). - -submit_eq_c( v(I,[]), B, Rest) :- !, - submit_eq_c1( Rest, B, I). -submit_eq_c( A, B, Rest) :- % c2 - A=v(_,[X^1]), var(X), - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - Hom = [A,B|Rest], - % 'solve_='( Hom). - nf_length( Hom, 0, Len), - log_deref( Len, Hom, [], HomD), - solve( HomD). -submit_eq_c( A, B, Rest) :- % c3 - Norm = [A,B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -submit_eq_c1( [], v(K,[X^P]), I) :- % c11 - var( X), - ( P = 1, !, arith_eval( -I/K, Val), export_binding( X, Val) - ; P = -1, !, arith_eval( -K/I, Val), export_binding( X, Val) - ). -submit_eq_c1( [], v(K,[NL^P]), I) :- % c12 - nonvar( NL), - ( P = 1, arith_eval( -I/K, Y) - ; P = -1, arith_eval( -K/I, Y) - ), - nl_invertible( NL, X, Y, Inv), - !, - nf( -Inv, S), - nf_add( X, S, New), - submit_eq( New). -submit_eq_c1( Rest, B, I) :- % c13 - B=v(_,[Y^1]), var(Y), - linear( Rest), - !, - % 'solve_='( [v(I,[]),B|Rest]). - Hom = [B|Rest], - nf_length( Hom, 0, Len), - normalize_scalar( I, Nonvar), - log_deref( Len, Hom, [], HomD), - add_linear_11( Nonvar, HomD, LinD), - solve( LinD). -submit_eq_c1( Rest, B, I) :- % c14 - Norm = [v(I,[]),B|Rest], - term_variables( Norm, Vs), - geler( Vs, resubmit_eq(Norm)). - -% ----------------------------------------------------------------------- - -submit_lt( []) :- fail. % trivial failure -submit_lt( [A|As]) :- - submit_lt( As, A). - -submit_lt( [], v(K,P)) :- submit_lt_b( P, K). -submit_lt( [B|Bs], A) :- submit_lt_c( Bs, A, B). - -submit_lt_b( [], I) :- !, arith_eval( I<0). -submit_lt_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_s_p_0( X) - ; - ineq_one_s_n_0( X) - ). -submit_lt_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_lt([v(K,P)])). - -submit_lt_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( strict, Y, K, I). -submit_lt_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_lt(Norm)) - ). - -submit_le( []). % trivial success -submit_le( [A|As]) :- - submit_le( As, A). - -submit_le( [], v(K,P)) :- submit_le_b( P, K). -submit_le( [B|Bs], A) :- submit_le_c( Bs, A, B). - -submit_le_b( [], I) :- !, arith_eval( I=<0). -submit_le_b( [X^1], K) :- - var(X), - !, - ( arith_eval( K>0) -> - ineq_one_n_p_0( X) - ; - ineq_one_n_n_0( X) - ). -submit_le_b( P, K) :- - term_variables( P, Vs), - geler( Vs, resubmit_le([v(K,P)])). - -submit_le_c( [], A, B) :- - A=v(I,[]), - B=v(K,[Y^1]), var(Y), - !, - ineq_one( nonstrict, Y, K, I). -submit_le_c( Rest, A, B) :- - Norm = [A,B|Rest], - ( linear(Norm) -> - 'solve_=<'( Norm) - ; - term_variables( Norm, Vs), - geler( Vs, resubmit_le(Norm)) - ). - -submit_ne( Norm1) :- - ( nf_constant( Norm1, K) -> - arith_eval( K=\=0) - ; linear( Norm1) -> - 'solve_=\\='( Norm1) - ; - term_variables( Norm1, Vs), - geler( Vs, resubmit_ne(Norm1)) - ). - - -linear( []). -linear( v(_,Ps)) :- linear_ps( Ps). -linear( [A|As]) :- - linear( A), - linear( As). - -linear_ps( []). -linear_ps( [V^1]) :- var( V). % excludes sin(_), ... - -% -% Goal delays until Term gets linear. -% At this time, Var will be bound to the normalform of Term. -% -:- meta_predicate wait_linear( ?, ?, :). -% -wait_linear( Term, Var, Goal) :- - nf( Term, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% -% geler clients -% -resubmit_eq( N) :- - repair( N, Norm), - submit_eq( Norm). - -resubmit_lt( N) :- - repair( N, Norm), - submit_lt( Norm). - -resubmit_le( N) :- - repair( N, Norm), - submit_le( Norm). - -resubmit_ne( N) :- - repair( N, Norm), - submit_ne( Norm). - -wait_linear_retry( Nf0, Var, Goal) :- - repair( Nf0, Nf), - ( linear( Nf) -> - Var = Nf, - call( Goal) - ; - term_variables( Nf, Vars), - geler( Vars, wait_linear_retry(Nf,Var,Goal)) - ). - -% ----------------------------------------------------------------------- - -/* -invertible( [v(Mone,[]),v(One,[X^Px,Y^Py])], Norm) :- - Px+Py =:= 0, - abs(Px) mod 2 =:= 1, % odd powers only ... - arith_eval( 1, One), - arith_eval( -1, Mone), - !, - ( Px < 0 -> - {X=\=0} - ; - {Y=\=0} - ), - nf( X-Y, Norm). % x=y -*/ - -nl_invertible( sin(X), X, Y, Res) :- arith_eval( asin(Y), Res). -nl_invertible( cos(X), X, Y, Res) :- arith_eval( acos(Y), Res). -nl_invertible( tan(X), X, Y, Res) :- arith_eval( atan(Y), Res). -nl_invertible( exp(B,C), X, A, Res) :- - ( nf_constant( B, Kb) -> - arith_eval(A>0), - arith_eval(Kb>0), - arith_eval(Kb=\=1), - X = C, - arith_eval( log(A)/log(Kb), Res) - ; nf_constant( C, Kc), - \+ (arith_eval(A=:=0),arith_eval(Kc=<0)), - X = B, - arith_eval( exp(A,1/Kc), Res) - ). - -% ----------------------------------------------------------------------- - -nf( X, Norm) :- var(X), !, - Norm = [v(One,[X^1])], - arith_eval( 1, One). -nf( X, Norm) :- number(X), !, - nf_number( X, Norm). -% -nf( rat(N,D), Norm) :- !, - nf_number( rat(N,D), Norm). -% -nf( #(Const), Norm) :- - monash_constant( Const, Value), - !, - ( arith_eval( 1, rat(1,1)) -> - nf_number( Value, Norm) % swallows #(zero) ... ok in Q - ; - arith_normalize( Value, N), % in R we want it - Norm = [v(N,[])] - ). -% -nf( -A, Norm) :- !, - nf( A, An), - arith_eval( -1, K), - nf_mul_factor( v(K,[]), An, Norm). -nf( +A, Norm) :- !, - nf( A, Norm). -% -nf( A+B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_add( An, Bn, Norm). -nf( A-B, Norm) :- !, - nf( A, An), - nf( -B, Bn), - nf_add( An, Bn, Norm). -% -nf( A*B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_mul( An, Bn, Norm). -nf( A/B, Norm) :- !, - nf( A, An), - nf( B, Bn), - nf_div( Bn, An, Norm). -% -nf( Term, Norm) :- - nonlin_1( Term, Arg, Skel, Sa1), - !, - nf( Arg, An), - nf_nonlin_1( Skel, An, Sa1, Norm). -nf( Term, Norm) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - !, - nf( A1, A1n), - nf( A2, A2n), - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, Norm). -% -nf( Term, _) :- - raise_exception( type_error(nf(Term,_),1,'a numeric expression',Term)). - -nf_number( N, Res) :- - nf_number( N), - arith_normalize( N, Normal), - ( arith_eval( Normal=:=0) -> - Res = [] - ; - Res = [v(Normal,[])] - ). - -nf_number( N) :- number( N), - !. /* MC 980507 */ -nf_number( N) :- compound( N), N=rat(_,_). % sicstus - -nonlin_1( abs(X), X, abs(Y), Y). -nonlin_1( sin(X), X, sin(Y), Y). -nonlin_1( cos(X), X, cos(Y), Y). -nonlin_1( tan(X), X, tan(Y), Y). - -nonlin_2( min(A,B), A,B, min(X,Y), X, Y). -nonlin_2( max(A,B), A,B, max(X,Y), X, Y). -nonlin_2( exp(A,B), A,B, exp(X,Y), X, Y). -nonlin_2( pow(A,B), A,B, exp(X,Y), X, Y). % pow->exp -nonlin_2( A^B, A,B, exp(X,Y), X, Y). - -nf_nonlin_1( Skel, An, S1, Norm) :- - ( nf_constant( An, S1) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; - S1 = An, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - -nf_nonlin_2( Skel, A1n, A2n, S1, S2, Norm) :- - ( nf_constant( A1n, S1), - nf_constant( A2n, S2) -> - nl_eval( Skel, Res), - nf_number( Res, Norm) - ; Skel=exp(_,_), - nf_constant( A2n, Exp), - integerp( Exp, I) -> - nf_power( I, A1n, Norm) - ; - S1 = A1n, - S2 = A2n, - arith_eval( 1, One), - Norm = [v(One,[Skel^1])] - ). - - -nl_eval( abs(X), R) :- arith_eval( abs(X), R). -nl_eval( sin(X), R) :- arith_eval( sin(X), R). -nl_eval( cos(X), R) :- arith_eval( cos(X), R). -nl_eval( tan(X), R) :- arith_eval( tan(X), R). -% -nl_eval( min(X,Y), R) :- arith_eval( min(X,Y), R). -nl_eval( max(X,Y), R) :- arith_eval( max(X,Y), R). -nl_eval( exp(X,Y), R) :- arith_eval( exp(X,Y), R). - -monash_constant( X, _) :- var(X), !, fail. -monash_constant( p, 3.14259265). -monash_constant( pi, 3.14259265). -monash_constant( e, 2.71828182). -monash_constant( zero, Eps) :- arith_eps( Eps). - -% -% check if a Nf consists of just a constant -% -nf_constant( [], Z) :- arith_eval( 0, Z). -nf_constant( [v(K,[])], K). - -% -% this depends on the polynf ordering, i.e. [] < [X^1] ... -% -split( [], [], Z) :- arith_eval( 0, Z). -split( [First|T], H, I) :- - ( First=v(I,[]) -> - H=T - ; - arith_eval( 0, I), - H = [First|T] - ). - -% -% runtime predicate -% -%:- mode nf_add( +, +, ?). -% -nf_add( [], Bs, Bs). -nf_add( [A|As], Bs, Cs) :- - nf_add( Bs, A, As, Cs). - -%:- mode nf_add( +, +, +, ?). -% -nf_add( [], A, As, Cs) :- Cs = [A|As]. -nf_add( [B|Bs], A, As, Cs) :- - A = v(Ka,Pa), - B = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_case( Rel, A, As, Cs, B, Bs, Ka, Kb, Pa). - -%:- mode nf_add_case( +, +, +, -, +, +, +, +, +). -% -nf_add_case( <, A, As, Cs, B, Bs, _, _, _) :- - Cs=[A|Rest], - nf_add( As, B, Bs, Rest). -nf_add_case( >, A, As, Cs, B, Bs, _, _, _) :- - Cs=[B|Rest], - nf_add( Bs, A, As, Rest). -nf_add_case( =, _, As, Cs, _, Bs, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - nf_add( As, Bs, Cs) - ; - Cs=[v(Kc,Pa)|Rest], - nf_add( As, Bs, Rest) - ). - -%:- mode nf_mul( +, +, -). -% -nf_mul( A, B, Res) :- - nf_length( A, 0, LenA), - nf_length( B, 0, LenB), - nf_mul_log( LenA, A, [], LenB, B, Res). - -nf_mul_log( 0, As, As, _, _, []) :- !. -nf_mul_log( 1, [A|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A, R). -nf_mul_log( 2, [A1,A2|As], As, Lb, B, R) :- !, - nf_mul_factor_log( Lb, B, [], A1, A1b), - nf_mul_factor_log( Lb, B, [], A2, A2b), - nf_add( A1b, A2b, R). -nf_mul_log( N, A0, A2, Lb, B, R) :- - P is N>>1, - Q is N-P, - nf_mul_log( P, A0, A1, Lb, B, Rp), - nf_mul_log( Q, A1, A2, Lb, B, Rq), - nf_add( Rp, Rq, R). - -%:- mode nf_add_2( +, +, -). -% -nf_add_2( Af, Bf, Res) :- % unfold: nf_add( [Af], [Bf], Res). - Af = v(Ka,Pa), - Bf = v(Kb,Pb), - compare( Rel, Pa, Pb), - nf_add_2_case( Rel, Af, Bf, Res, Ka, Kb, Pa). - -%:- mode nf_add_2_case( +, +, +, -, +, +, +). -% -nf_add_2_case( <, Af, Bf, [Af,Bf], _, _, _). -nf_add_2_case( >, Af, Bf, [Bf,Af], _, _, _). -nf_add_2_case( =, _, _, Res, Ka, Kb, Pa) :- - arith_eval( Ka+Kb, Kc), - ( arith_eval( Kc=:=0 ) -> - Res = [] - ; - Res=[v(Kc,Pa)] - ). - -% -% multiply with a scalar =\= 0 -% -nf_mul_k( [], _, []). -nf_mul_k( [v(I,P)|Vs], K, [v(Ki,P)|Vks]) :- - arith_eval( K*I, Ki), - nf_mul_k( Vs, K, Vks). - -nf_mul_factor( v(K,[]), Sum, Res) :- !, nf_mul_k( Sum, K, Res). -nf_mul_factor( F, Sum, Res) :- - nf_length( Sum, 0, Len), - nf_mul_factor_log( Len, Sum, [], F, Res). - -nf_mul_factor_log( 0, As, As, _, []) :- !. -nf_mul_factor_log( 1, [A|As], As, F, [R]) :- !, - mult( A, F, R). -nf_mul_factor_log( 2, [A,B|As], As, F, Res) :- !, - mult( A, F, Af), - mult( B, F, Bf), - nf_add_2( Af, Bf, Res). -nf_mul_factor_log( N, A0, A2, F, R) :- - P is N>>1, - Q is N-P, - nf_mul_factor_log( P, A0, A1, F, Rp), - nf_mul_factor_log( Q, A1, A2, F, Rq), - nf_add( Rp, Rq, R). - -mult( v(Ka,La), v(Kb,Lb), v(Kc,Lc)) :- - arith_eval( Ka*Kb, Kc), - pmerge( La, Lb, Lc). - -pmerge( [], Bs, Bs). -pmerge( [A|As], Bs, Cs) :- - pmerge( Bs, A, As, Cs). - -%:- mode pmerge(+,+,+,-). -% -pmerge( [], A, As, Res) :- Res = [A|As]. -pmerge( [B|Bs], A, As, Res) :- - A=Xa^Ka, - B=Xb^Kb, - compare( R, Xa, Xb), - pmerge_case( R, A, As, Res, B, Bs, Ka, Kb, Xa). - -%:- mode pmerge_case( +, +, +, -, +, +, +, +, ?). -% -pmerge_case( <, A, As, Res, B, Bs, _, _, _) :- - Res = [A|Tail], - pmerge( As, B, Bs, Tail). -pmerge_case( >, A, As, Res, B, Bs, _, _, _) :- - Res = [B|Tail], - pmerge( Bs, A, As, Tail). -pmerge_case( =, _, As, Res, _, Bs, Ka, Kb, Xa) :- - Kc is Ka+Kb, - ( Kc=:=0 -> - pmerge( As, Bs, Res) - ; - Res = [Xa^Kc|Tail], - pmerge( As, Bs, Tail) - ). - -nf_div( [], _, _) :- !, zero_division. -nf_div( [v(K,P)], Sum, Res) :- !, - arith_eval( 1/K, Ki), - mult_exp( P, -1, Pi), - nf_mul_factor( v(Ki,Pi), Sum, Res). -nf_div( D, A, [v(One,[(A/D)^1])]) :- - arith_eval( 1, One). - -zero_division :- fail. % raise_exception(_) ? - -mult_exp( [], _, []). -mult_exp( [X^P|Xs], K, [X^I|Tail]) :- - I is K*P, - mult_exp( Xs, K, Tail). - -% -% raise to integer powers -% -% | ?- time({(1+X+Y+Z)^15=0}). -% Timing 00:00:02.610 2.610 iterative -% Timing 00:00:00.660 0.660 binomial -nf_power( N, Sum, Norm) :- - integer( N), - compare( Rel, N, 0), - ( Rel = < -> - Pn is -N, - % nf_power_pos( Pn, Sum, Inorm), - binom( Sum, Pn, Inorm), - arith_eval( 1, One), - nf_div( Inorm, [v(One,[])], Norm) - ; Rel = > -> - % nf_power_pos( N, Sum, Norm) - binom( Sum, N, Norm) - ; Rel = = -> % 0^0 is indeterminate but we say 1 - arith_eval( 1, One), - Norm = [v(One,[])] - ). - - -% -% N>0 -% -nf_power_pos( 1, Sum, Norm) :- !, Sum = Norm. -nf_power_pos( N, Sum, Norm) :- - N1 is N-1, - nf_power_pos( N1, Sum, Pn1), - nf_mul( Sum, Pn1, Norm). - -% -% N>0 -% -binom( Sum, 1, Power) :- !, Power = Sum. -binom( [], _, []). -binom( [A|Bs], N, Power) :- - ( Bs=[] -> - nf_power_factor( A, N, Ap), - Power = [Ap] - ; Bs=[_|_] -> - arith_eval( 1, One), - factor_powers( N, A, v(One,[]), Pas), - sum_powers( N, Bs, [v(One,[])], Pbs, []), - combine_powers( Pas, Pbs, 0, N, 1, [], Power) - ). - -combine_powers( [], [], _, _, _, Pi, Pi). -combine_powers( [A|As], [B|Bs], L, R, C, Pi, Po) :- - nf_mul( A, B, Ab), - arith_normalize( C, Cn), - nf_mul_k( Ab, Cn, Abc), - nf_add( Abc, Pi, Pii), - L1 is L+1, - R1 is R-1, - C1 is C*R//L1, - combine_powers( As, Bs, L1, R1, C1, Pii, Po). - - -nf_power_factor( v(K,P), N, v(Kn,Pn)) :- - arith_normalize( N, Nn), - arith_eval( exp(K,Nn), Kn), - mult_exp( P, N, Pn). - -factor_powers( 0, _, Prev, [[Prev]]) :- !. -factor_powers( N, F, Prev, [[Prev]|Ps]) :- - N1 is N-1, - mult( Prev, F, Next), - factor_powers( N1, F, Next, Ps). - -sum_powers( 0, _, Prev, [Prev|Lt], Lt) :- !. -sum_powers( N, S, Prev, L0, Lt) :- - N1 is N-1, - nf_mul( S, Prev, Next), - sum_powers( N1, S, Next, L0, [Prev|Lt]). - -% ------------------------------------------------------------------------------ - -repair( Sum, Norm) :- - nf_length( Sum, 0, Len), - repair_log( Len, Sum, [], Norm). - -repair_log( 0, As, As, []) :- !. -repair_log( 1, [v(Ka,Pa)|As], As, R) :- !, - repair_term( Ka, Pa, R). -repair_log( 2, [v(Ka,Pa),v(Kb,Pb)|As], As, R) :- !, - repair_term( Ka, Pa, Ar), - repair_term( Kb, Pb, Br), - nf_add( Ar, Br, R). -repair_log( N, A0, A2, R) :- - P is N>>1, - Q is N-P, - repair_log( P, A0, A1, Rp), - repair_log( Q, A1, A2, Rq), - nf_add( Rp, Rq, R). - - -repair_term( K, P, Norm) :- - length( P, Len), - arith_eval( 1, One), - repair_p_log( Len, P, [], Pr, [v(One,[])], Sum), - nf_mul_factor( v(K,Pr), Sum, Norm). - -repair_p_log( 0, Ps, Ps, [], L0, L0) :- !. -repair_p_log( 1, [X^P|Ps], Ps, R, L0, L1) :- !, - repair_p( X, P, R, L0, L1). -repair_p_log( 2, [X^Px,Y^Py|Ps], Ps, R, L0,L2) :- !, - repair_p( X, Px, Rx, L0, L1), - repair_p( Y, Py, Ry, L1, L2), - pmerge( Rx, Ry, R). -repair_p_log( N, P0, P2, R, L0, L2) :- - P is N>>1, - Q is N-P, - repair_p_log( P, P0, P1, Rp, L0, L1), - repair_p_log( Q, P1, P2, Rq, L1, L2), - pmerge( Rp, Rq, R). - - -%vsc: added ! (01/06/06) -repair_p( Term, P, [Term^P], L0, L0) :- var( Term), !. -repair_p( Term, P, [], L0, L1) :- nonvar( Term), - repair_p_one( Term, TermN), - nf_power( P, TermN, TermNP), - nf_mul( TermNP, L0, L1). - -% -% An undigested term a/b is distinguished from an -% digested one by the fact that its arguments are -% digested -> cuts after repair of args! -% -repair_p_one( Term, TermN) :- - nf_number( Term, TermN), % freq. shortcut for nf/2 case below - !. -repair_p_one( A1/A2, TermN) :- - repair( A1, A1n), - repair( A2, A2n), - !, - nf_div( A2n, A1n, TermN). -repair_p_one( Term, TermN) :- - nonlin_1( Term, Arg, Skel, Sa), - repair( Arg, An), - !, - nf_nonlin_1( Skel, An, Sa, TermN). -repair_p_one( Term, TermN) :- - nonlin_2( Term, A1,A2, Skel, Sa1, Sa2), - repair( A1, A1n), - repair( A2, A2n), - !, - nf_nonlin_2( Skel, A1n, A2n, Sa1, Sa2, TermN). -repair_p_one( Term, TermN) :- - nf( Term, TermN). - -%:- mode nf_length( +, +, -). -% -nf_length( [], Li, Li). -nf_length( [_|R], Li, Lo) :- - Lii is Li+1, - nf_length( R, Lii, Lo). - -% ------------------------------------------------------------------------------ - -nf2term( [], Z) :- arith_eval( 0, Z). -nf2term( [F|Fs], T) :- - f02t( F, T0), - yfx( Fs, T0, T). - -yfx( [], T0, T0). -yfx( [F|Fs], T0, TN) :- - fn2t( F, Ft, Op), - T1 =.. [Op,T0,Ft], - yfx( Fs, T1, TN). - -f02t( v(K,P), T) :- - ( P = [] -> - T = K - ; arith_eval( K=:=1) -> - p2term( P, T) - ; arith_eval( K=:= -1) -> - T = -Pt, - p2term( P, Pt) - ; - T = K*Pt, - p2term( P, Pt) - ). - -fn2t( v(K,P), Term, Op) :- - ( arith_eval( K=:=1) -> - Term = Pt, Op = + - ; arith_eval( K=:= -1) -> - Term = Pt, Op = - - ; arith_eval( K<0) -> - arith_eval( -K, Kf), - Term = Kf*Pt, Op = - - ; - Term = K*Pt, Op = + - ), - p2term( P, Pt). - -p2term( [X^P|Xs], Term) :- - ( Xs=[] -> - pe2term( X, Xt), - exp2term( P, Xt, Term) - ; Xs=[_|_] -> - Term = Xst*Xtp, - pe2term( X, Xt), - exp2term( P, Xt, Xtp), - p2term( Xs, Xst) - ). - -exp2term( 1, X, X) :- !. -exp2term(-1, X, One/X) :- !, arith_eval( 1, One). -exp2term( P, X, Term) :- - arith_normalize( P, Pn), - % Term = exp(X,Pn). - Term = X^Pn. - -pe2term( X, Term) :- var(X), Term = X. -pe2term( X, Term) :- nonvar(X), - X =.. [F|Args], - pe2term_args( Args, Argst), - Term =.. [F|Argst]. - -pe2term_args( [], []). -pe2term_args( [A|As], [T|Ts]) :- - nf2term( A, T), - pe2term_args( As, Ts). - diff --git a/CLPQR/clpr/nfr.pl b/CLPQR/clpr/nfr.pl deleted file mode 100644 index 3689da992..000000000 --- a/CLPQR/clpr/nfr.pl +++ /dev/null @@ -1,76 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nfr.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - -:- module( nfr, - [ - {}/1, - entailed/1, - wait_linear/3, - - nf/2, - repair/2, - nf_constant/2, - split/3, - transg/3 - ]). - -:- use_module( arith_r). - -:- use_module( clpr, '../clpr', - [ - 'solve_<'/1, - 'solve_=<'/1, - 'solve_=\='/1, - add_linear_11/3, - export_binding/2, - ineq_one/4, - ineq_one_n_n_0/1, - ineq_one_n_p_0/1, - ineq_one_s_n_0/1, - ineq_one_s_p_0/1, - log_deref/4, - normalize_scalar/2, - solve/1 - ]). - -:- ensure_loaded( nf). - -transg( resubmit_eq(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term=Z} ]. -transg( resubmit_lt(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term= - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term=\=Z} ]. -transg( wait_linear_retry(Nf,Res,Goal)) --> - { - nf2term( Nf, Term) - }, - [ clpr:{Term=Res}, Goal ]. diff --git a/CLPQR/clpr/nfr.yap b/CLPQR/clpr/nfr.yap deleted file mode 100644 index 930146ce7..000000000 --- a/CLPQR/clpr/nfr.yap +++ /dev/null @@ -1,75 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% clp(q,r) version 1.3.3 % -% % -% (c) Copyright 1992,1993,1994,1995 % -% Austrian Research Institute for Artificial Intelligence (OFAI) % -% Schottengasse 3 % -% A-1010 Vienna, Austria % -% % -% File: nfr.pl % -% Author: Christian Holzbaur christian@ai.univie.ac.at % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- module( nfr, - [ - {}/1, - entailed/1, - wait_linear/3, - - nf/2, - repair/2, - nf_constant/2, - split/3, - transg/3 - ]). - -:- use_module( arith_r). - -:- use_module( clpr, '../clpr', - [ - 'solve_<'/1, - 'solve_=<'/1, - 'solve_=\\='/1, % vsc \\ - add_linear_11/3, - export_binding/2, - ineq_one/4, - ineq_one_n_n_0/1, - ineq_one_n_p_0/1, - ineq_one_s_n_0/1, - ineq_one_s_p_0/1, - log_deref/4, - normalize_scalar/2, - solve/1 - ]). - -:- ensure_loaded(nf). - -transg( resubmit_eq(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term=Z} ]. -transg( resubmit_lt(Nf)) --> - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term= - { - nf2term( [], Z), - nf2term( Nf, Term) - }, - [ clpr:{Term=\=Z} ]. -transg( wait_linear_retry(Nf,Res,Goal)) --> - { - nf2term( Nf, Term) - }, - [ clpr:{Term=Res}, Goal ]. diff --git a/m4/Atoms.h.m4 b/m4/Atoms.h.m4 deleted file mode 100644 index 93816d760..000000000 --- a/m4/Atoms.h.m4 +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Atoms.h.m4 * -* Last rev: 19/2/88 * -* mods: * -* comments: atom properties header file for YAP * -* * -*************************************************************************/ - -#undef EXTERN -#ifndef ADTDEFS_C -#define EXTERN static -#else -#define EXTERN -#endif - -/********* operations for atoms ****************************************/ - -/* Atoms are assumed to be uniquely represented by an OFFSET and to have - associated with them a struct of type AtomEntry - The two functions - RepAtom : Atom -> *AtomEntry - AbsAtom : *AtomEntry -> Atom - are used to encapsulate the implementation of atoms -*/ - -typedef struct AtomEntryStruct *Atom; -typedef struct PropEntryStruct *Prop; - - -/* I can only define the structure after I define the actual atoms */ - -/* atom structure */ -typedef struct AtomEntryStruct { - Atom NextOfAE; /* used to build hash chains */ - Prop PropsOfAE; /* property list for this atom */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t ARWLock; -#endif - - char StrOfAE[MIN_ARRAY]; /* representation of atom as a string */ -} -AtomEntry; - -/* Props and Atoms are stored in chains, ending with a NIL */ -#if USE_OFFSETS -# define EndOfPAEntr(P) ( Addr(P) == AtomBase) -#else -# define EndOfPAEntr(P) ( Addr(P) == NIL ) -#endif - -#define AtomName(at) RepAtom(at)->StrOfAE - - -/* ********************** Properties **********************************/ - -#if USE_OFFSETS -#define USE_OFFSETS_IN_PROPS 1 -#else -#define USE_OFFSETS_IN_PROPS 0 -#endif - -typedef SFLAGS PropFlags; - -/* basic property entry structure */ -typedef struct PropEntryStruct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - } PropEntry; - -/* ************************* Functors **********************************/ - - /* Functor data type - abstype Functor = atom # int - with MkFunctor(a,n) = ... - and NameOfFunctor(f) = ... - and ArityOfFunctor(f) = ... */ - -#define MaxArity 255 - - -#define FunctorProperty ((PropFlags)(0xbb00)) - -/* functor property */ -typedef struct FunctorEntryStruct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - unsigned int ArityOfFE; /* arity of functor */ - Atom NameOfFE; /* back pointer to owner atom */ - Prop PropsOfFE; /* pointer to list of properties for this functor */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t FRWLock; -#endif -} FunctorEntry; - -typedef FunctorEntry *Functor; - diff --git a/m4/Tags_24bits.h.m4 b/m4/Tags_24bits.h.m4 deleted file mode 100644 index bf37df131..000000000 --- a/m4/Tags_24bits.h.m4 +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_24bits.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Tag Scheme for machines with 24 bits adresses (m68000) * -* version: $Id: Tags_24bits.h.m4,v 1.2 2003-06-06 13:16:40 vsc Exp $ * -*************************************************************************/ - - /* Version for 24 bit addresses (68000) - Each term is represented internally as an unsigned 32 bit integer as - follows: - tag value - ints 1m1000 numeric value - floats 1m1001 floating point value - pairs 1mr10. ptr to pair - aplied functor 1mr01. ptr to functor followed by args - ref 0mr000 address of cell - undefined 0mr000 pointing to itself - -*/ - -#define AllTagBits 0xfc000000L -#define TagBits 0xbc000000L -#define MaskAdr 0x03ffffffL -#define AdrHiBit 0x02000000L -#define NumberTag 0xa0000000L -#define FloatTag 0xa4000000L -#define AtomTag 0x84000000L -#define PairTag 0x90000000L -#define ApplTag 0x88000000L -#define RefTag 0x80000000L - -#define MaskBits 6 - -#define PairBit 0x10000000L -#define ApplBit 0x08000000L -#define CompBits 0x18000000L -#define NumberMask 0xb8000000L -#define MAX_ABS_INT /* 0xfe00000LL */ ((((UInt)(1<<7))-1) << SHIFT_HIGH_TAG) - -#define TagOf(X) (Unsigned(X) & TagBits) -#define NonTagPart(X) (Signed(X) & MaskAdr) -#define TAGGEDA(TAG,V) (TAG | Unsigned(V)) -#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V))) -#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)) -#define BitOn(Bit,V) (Bit & Unsigned(V)) -#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag) - -/* bits that should not be used by anyone but us */ -#define YAP_PROTECTED_MASK 0x00000000L - -Inline(IsVarTerm, int, Term, t, Signed(t) >= 0) -Inline(IsNonVarTerm, int, Term, t, Signed(t) < 0) -Inline(RepPair, Term *, Term, t, NonTagPart(t)) -Inline(AbsPair, Term, Term *, p, TAGGEDA(PairTag, (p))) -Inline(IsPairTerm, Int, Term, t, BitOn(PairBit, (t))) -Inline(RepAppl, Term *, Term, t, NonTagPart(t)) -Inline(AbsAppl, Term, Term *, p, TAGGEDA(ApplTag, (p))) -Inline(IsApplTerm, Int, Term, t, BitOn(ApplBit, (t))) -Inline(IsAtomOrIntTerm, Int, Term, t, !(Unsigned(t) & CompBits)) - -Inline2(AdjustPtr, Term, Term, t, Term, off, (t)+off) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, (t)+off) - -static inline Int -IntOfTerm(Term t) -{ - Int n; - n = (Unsigned(t) & MaskPrim) >> 2; - - if (Unsigned(t) & AdrHiBit) - n |= 0xfc000000; - return (n); -} - diff --git a/m4/Tags_32LowTag.h.m4 b/m4/Tags_32LowTag.h.m4 deleted file mode 100644 index 998acbb3d..000000000 --- a/m4/Tags_32LowTag.h.m4 +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_32LowTag.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Original Tag Scheme for machines with 32 bits adresses * -* version: $Id: Tags_32LowTag.h.m4,v 1.3 2003-06-06 13:16:40 vsc Exp $ * -*************************************************************************/ - -#define TAG_LOW_BITS_32 1 - - /* Version for 32 bit addresses machines, - Each term is represented internally as an unsigned 32 bit integer as - follows: - tag value - ints m.....110 numeric value - atoms m.....010 offset of atom entry - pairs mr.....11 ptr to pair - aplied functor mr.....01 ptr to functor followed by args - ref mr.....00 address of cell - undefined mr.....00 address of cell pointing to itself - - functors are represented as ptrs to the functor entry in the atom -property list - -*/ - -#define SHIFT_LOW_TAG 2 -#define SHIFT_HIGH_TAG 2 - -#define MKTAG(HI,LO) ((((UInt) (HI))<>1) & ~LowTagBits) -#define TAGGED(TAG,V) (((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)|(TAG)) -#define NONTAGGED(TAG,V) ((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1) -#define TAGGEDA(TAG,V) ((Unsigned(V) << 1)|(TAG)) -#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag) - -/* bits that should not be used by anyone but us */ -#define YAP_PROTECTED_MASK 0xc0000000L - -Inline(IsVarTerm, int, Term, t, !((t) & LowTagBits)) -Inline(IsNonVarTerm, int, Term, t, ((t) & LowTagBits)) -Inline(RepPair, Term *, Term, t, (t)-PairBits) -Inline(AbsPair, Term, Term *, p, Unsigned(p)+PairBits) -Inline(IsPairTerm, Int, Term, t, (((t) & LowTagBits) == PairBits)) -Inline(RepAppl, Term *, Term, t, ((t)-ApplBit)) -Inline(AbsAppl, Term, Term *, p, Unsigned(p)+ApplBit) -Inline(IsApplTerm, Int, Term, t, (((t) & LowTagBits) == ApplBit)) -Inline(IsAtomOrIntTerm, Int, Term, t, (((t) & LowTagBits) == 2)) - -Inline2(AdjustPtr, Term, Term, t, Term, off, (t)+off) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, (t)+off) - -Inline(IntOfTerm, Int, Term, t, ((Int)(t << 1))>>(SHIFT_LOW_TAG+SHIFT_HIGH_TAG+1)) - diff --git a/m4/Tags_32Ops.h.m4 b/m4/Tags_32Ops.h.m4 deleted file mode 100644 index da6e8a502..000000000 --- a/m4/Tags_32Ops.h.m4 +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_32Ops.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Original Tag Scheme for machines with 32 bits adresses * -* version: $Id: Tags_32Ops.h.m4,v 1.3 2003-06-06 13:16:40 vsc Exp $ * -*************************************************************************/ - -/* - - Version for 32 bit addresses machines, - Each term is represented internally as an unsigned 32 bit integer as - follows: - tag value - ints 1m1....01 numeric value - atoms 1m0....01 offset of atom entry - pairs 1mr....11 ptr to pair - aplied functor 1mr....00 ptr to functor followed by args - undefined 0mr....00 address of cell pointing to itself - - functors are represented as ptrs to the functor entry in the atom -property list - - This version speeds up access to lists and to compound -terms by using the XOR and NOT operations to build their tags. This -saves operations on RISC machines. - - As a further optimisation, only pairs or compound terms have -the second lowest bit set. This allows one to recognise lists or -compound terms with a single operation. - - The main problem is that the default value of the M and R bits for GC -are now 1 in compound terms and structures. - -*/ - -#define TAGS_FAST_OPS 1 - -#define SHIFT_HIGH_TAG 29 - -#define MKTAG(HI,LO) ((((UInt) (HI))<= 0) -Inline(IsNonVarTerm, int, Term, t, Signed(t) < 0) -#if UNIQUE_TAG_FOR_PAIRS -Inline(RepPair, Term *, Term, t, (~(t))) -Inline(AbsPair, Term, Term *, p, (~Unsigned(p))) -Inline(IsPairTerm, Int, Term, t, ((t) & PairBit)) -Inline(RepAppl, Term *, Term, t, (-Signed(t))) -Inline(AbsAppl, Term, Term *, p, (-Signed(p))) -Inline(IsApplTerm, Int, Term, t, (!((t) & LowTagBits))) -#else -Inline(RepPair, Term *, Term, t, (-Signed(t))) -Inline(AbsPair, Term, Term *, p, ((CELL)(-Signed(p)))) -Inline(IsPairTerm, Int, Term, t, (!((t) & LowTagBits))) -Inline(RepAppl, Term *, Term, t, (~(t))) -Inline(AbsAppl, Term, Term *, p, (~Unsigned(p))) -Inline(IsApplTerm, Int, Term, t, ((t) & ApplBit)) -#endif -Inline(IsAtomOrIntTerm, Int, Term, t, ((Unsigned(t) & LowTagBits) == 0x2)) - -Inline(IntOfTerm, Int, Term, t, (Int)(Unsigned(t) << 3) >> 5) - -#if UNIQUE_TAG_FOR_PAIRS -Inline2(AdjustPtr, Term, Term, t, Term, off, ((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsPairTerm(t) ? (CELL)AbsPair((CELL *)((CELL)RepPair(t)+(off))) : (t)-(off)))) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, IsVarTerm(t) ? (t)+(off) : (t)-(off)) -#else -Inline2(AdjustPtr, Term, Term, t, Term, off, ((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off)))) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, IsVarTerm(t) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off))) -#endif - - diff --git a/m4/Tags_32bits.h.m4 b/m4/Tags_32bits.h.m4 deleted file mode 100644 index f744b290e..000000000 --- a/m4/Tags_32bits.h.m4 +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_32bits.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Original Tag Scheme for machines with 32 bits adresses * -* version: $Id: Tags_32bits.h.m4,v 1.1.1.1 2001-04-09 19:53:46 vsc Exp $ * -*************************************************************************/ - -/* Original version for 32 bit addresses machines, - Each term is represented internally as an unsigned 32 bit integer as - follows: - tag value - ints 1m1....00 numeric value - atoms 1m0....00 offset of atom entry - pairs 1mr....01 ptr to pair - aplied functor 1mr....10 ptr to functor followed by args - ref 0mr....00 address of cell - undefined 0mr....00 address of cell pointing to itself - - functors are represented as ptrs to the functor entry in the atom -property list - -*/ - -#define SHIFT_HIGH_TAG 29 - -#define MKTAG(HI,LO) ((((UInt) (HI))<= 0) -Inline(IsNonVarTerm, int, Term, t, Signed(t) < 0) -Inline(RepPair, Term *, Term, t, NonTagPart(t)) -Inline(AbsPair, Term, Term *, p, TAGGEDA(PairTag, (p))) -Inline(IsPairTerm, Int, Term, t, BitOn(PairBit, (t))) -Inline(RepAppl, Term *, Term, t, NonTagPart(t)) -Inline(AbsAppl, Term, Term *, p, TAGGEDA(ApplTag, (p))) -Inline(IsApplTerm, Int, Term, t, BitOn(ApplBit, (t))) -Inline(IsAtomOrIntTerm, int, Term, t, ((Unsigned(t) & LowTagBits) == 0)) - -Inline2(AdjustPtr, Term, Term, t, Term, off, (t)+off) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, (t)+off) - -Inline(IntOfTerm, Int, Term, t, ((Int)(t << 3))>>(3+2)) - - diff --git a/m4/Tags_64bits.h.m4 b/m4/Tags_64bits.h.m4 deleted file mode 100644 index 8757eceff..000000000 --- a/m4/Tags_64bits.h.m4 +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_32Ops.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Original Tag Scheme for machines with 32 bits adresses * -* version: $Id: Tags_64bits.h.m4,v 1.5 2005-04-15 19:06:37 vsc Exp $ * -*************************************************************************/ - -#define TAG_64BITS 1 - -/* Version for 64 bit addresses machines, - Each term is represented internally as an unsigned 64 bit integer as - follows: - tag value - ints 0m1....001 numeric value - atoms 0m0....001 offset of atom entry - pairs 0mr....011 ptr to pair - aplied functor 0mr....101 ptr to functor followed by args - undefined 0mr....000 address of cell pointing to itself - - functors are represented as ptrs to the functor entry in the atom -property list - - We rely on the fact that addresses are always multiple of 8. - -*/ - -#define SHIFT_HIGH_TAG 62 - -#define MKTAG(HI,LO) ((((UInt) (HI))<> 6) - diff --git a/m4/Tags_64ops.h.m4 b/m4/Tags_64ops.h.m4 deleted file mode 100644 index 985a0b370..000000000 --- a/m4/Tags_64ops.h.m4 +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Tags_32Ops.h.m4 * -* Last rev: December 90 * -* mods: * -* comments: Original Tag Scheme for machines with 32 bits adresses * -* version: $Id: Tags_64ops.h.m4,v 1.3 2003-06-06 13:16:40 vsc Exp $ * -*************************************************************************/ - -/* - - Version for 32 bit addresses machines, - Each term is represented internally as an unsigned 32 bit integer as - follows: - tag value - ints 1m1....01 numeric value - atoms 1m0....01 offset of atom entry - pairs 1mr....11 ptr to pair - aplied functor 1mr....00 ptr to functor followed by args - undefined 0mr....00 address of cell pointing to itself - - functors are represented as ptrs to the functor entry in the atom -property list - - This version speeds up access to lists and to compound -terms by using the XOR and NOT operations to build their tags. This -saves operations on RISC machines. - - As a further optimisation, only pairs or compound terms have -the second lowest bit set. This allows one to recognise lists or -compound terms with a single operation. - - The main problem is that the default value of the M and R bits for GC -are now 1 in compound terms and structures. - -*/ - -# define SHIFT_HIGH_TAG 61 - -#define MKTAG(HI,LO) ((((UInt) (HI))<= 0) -Inline(IsNonVarTerm, int, Term, t, Signed(t) < 0) -#if UNIQUE_TAG_FOR_PAIRS -Inline(RepPair, Term *, Term, t, (~(t))) -Inline(AbsPair, Term, Term *, p, (~Unsigned(p))) -Inline(IsPairTerm, Int, Term, t, ((t) & PairBit)) -Inline(RepAppl, Term *, Term, t, (-(t))) -Inline(AbsAppl, Term, Term *, p, (-Unsigned(p))) -Inline(IsApplTerm, Int, Term, t, (!((t) & LowTagBits))) -#else -Inline(RepPair, Term *, Term, t, (-(t))) -Inline(AbsPair, Term, Term *, p, (-Unsigned(p))) -Inline(IsPairTerm, Int, Term, t, (!((t) & LowTagBits))) -Inline(RepAppl, Term *, Term, t, (~(t))) -Inline(AbsAppl, Term, Term *, p, (~Unsigned(p))) -Inline(IsApplTerm, Int, Term, t, ((t) & ApplBit)) -#endif -Inline(IsAtomOrIntTerm, Int, Term, t, (Unsigned(t) & LowTagBits == 0x2)) - -Inline(IntOfTerm, Int, Term, t, (((Int)((t) << 3)) >> 5)) - -Inline2(AdjustPtr, Term, Term, t, Term, off, (IsVarTerm(t) ? (t)+off : (IsPairTerm(t) ? AbsPair((CELL *)(Unsigned(RepPair(t))+off)) : AbsAppl((CELL *)(Unsigned(RepAppl(t))+off))))) -Inline2(AdjustIDBPtr, Term, Term, t, Term, off, (IsVarTerm(t) ? (t)+off : (IsPairTerm(t) ? AbsPair((CELL *)(Unsigned(RepPair(t))+off)) : AbsAppl((CELL *)(Unsigned(RepAppl(t))+off))))) - diff --git a/m4/TermExt.h.m4 b/m4/TermExt.h.m4 deleted file mode 100644 index 43430107c..000000000 --- a/m4/TermExt.h.m4 +++ /dev/null @@ -1,267 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: TermExt.h * -* mods: * -* comments: Extensions to standard terms for YAP * -* version: $Id: TermExt.h.m4,v 1.17 2004-12-02 06:06:47 vsc Exp $ * -*************************************************************************/ - -#ifdef USE_SYSTEM_MALLOC -#define SF_STORE (&(Yap_heap_regs->funcs)) -#else -#define SF_STORE ((special_functors *)HEAP_INIT_BASE) -#endif - -#if USE_OFFSETS -#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar))) -#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil))) -#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot))) -#else -#define AtomFoundVar AbsAtom(&(SF_STORE->AtFoundVar)) -#define AtomNil AbsAtom(&(SF_STORE->AtNil)) -#define AtomDot AbsAtom(&(SF_STORE->AtDot)) -#endif - -#define TermFoundVar MkAtomTerm(AtomFoundVar) -#define TermNil MkAtomTerm(AtomNil) -#define TermDot MkAtomTerm(AtomDot) - -#if defined(IN_SECOND_QUADRANT) && !GC_NO_TAGS -typedef enum { - db_ref_e = sizeof(Functor *)|RBIT, - long_int_e = 2*sizeof(Functor *)|RBIT, -#ifdef USE_GMP - big_int_e = 3*sizeof(Functor *)|RBIT, - double_e = 4*sizeof(Functor *)|RBIT -#else - double_e = 3*sizeof(Functor *)|RBIT -#endif -} blob_type; -#else -typedef enum { - db_ref_e = sizeof(Functor *), - long_int_e = 2*sizeof(Functor *), -#ifdef USE_GMP - big_int_e = 3*sizeof(Functor *), - double_e = 4*sizeof(Functor *) -#else - double_e = 3*sizeof(Functor *) -#endif -} blob_type; -#endif - -#define FunctorDBRef ((Functor)(db_ref_e)) -#define FunctorLongInt ((Functor)(long_int_e)) -#ifdef USE_GMP -#define FunctorBigInt ((Functor)(big_int_e)) -#endif -#define FunctorDouble ((Functor)(double_e)) -#define EndSpecials (double_e) - -Destructor(Functor, BlobOf, blob_type, f, (CELL)f) - -#ifdef COROUTINING - -typedef struct { - /* what to do when someone tries to bind our term to someone else - in some predefined context */ - void (*bind_op)(Term *, Term); - /* what to do if someone wants to copy our constraint */ - int (*copy_term_op)(CELL *, CELL ***, CELL *); - /* copy the constraint into a term and back */ - Term (*to_term_op)(CELL *); - int (*term_to_op)(Term, Term); - /* op called to do marking in GC */ - void (*mark_op)(CELL *); -} ext_op; - -/* known delays */ -typedef enum { - empty_ext = 0*sizeof(ext_op), /* default op, this should never be called */ - attvars_ext = 1*sizeof(ext_op) /* support for attributed variables */ - /* add your own extensions here */ - /* keep this one */ -} exts; - - -/* array with the ops for your favourite extensions */ -extern ext_op attas[attvars_ext+1]; - -#endif - -/* make sure that these data structures are the first thing to be allocated - in the heap when we start the system */ -typedef struct special_functors_struct -{ - AtomEntry AtFoundVar; - char AtFoundVarChars[8]; - AtomEntry AtNil; - char AtNilChars[8]; - AtomEntry AtDot; - char AtDotChars[8]; -} -special_functors; - -#if USE_SYSTEM_MALLOC -#define MAX_SPECIALS_TAG (4*4096) -#else -#define MAX_SPECIALS_TAG ((CELL)AtomBase) -#endif - -#if SIZEOF_DOUBLE == SIZEOF_LONG_INT -#if GC_NO_TAGS -Inline(MkFloatTerm, Term, Float, dbl, (H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[2]=(2*sizeof(CELL)+EndSpecials),H+=3,AbsAppl(H-3))) -#else -Inline(MkFloatTerm, Term, Float, dbl, (H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3))) -#endif - -Destructor(Term, FloatOf, Float, t, *(Float *)(RepAppl(t)+1)) - -#define InitUnalignedFloat() - -#else - -#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT - -inline EXTERN Float STD_PROTO(CpFloatUnaligned,(CELL *)); - -inline EXTERN void STD_PROTO(AlignGlobalForDouble,(void)); - -#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4) - -#ifdef i386 -inline EXTERN Float -CpFloatUnaligned(CELL *ptr) -{ - return *((Float *)(ptr+1)); -} - -#else -/* first, need to address the alignment problem */ -inline EXTERN Float -CpFloatUnaligned(CELL *ptr) -{ - union { Float f; CELL d[2]; } u; - u.d[0] = ptr[1]; - u.d[1] = ptr[2]; - return(u.f); -} - -#endif - -#if GC_NO_TAGS -Inline(MkFloatTerm, Term, Float, dbl, (AlignGlobalForDouble(), H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[3]=(3*sizeof(CELL)+EndSpecials), H+=4, AbsAppl(H-4))) -#else -Inline(MkFloatTerm, Term, Float, dbl, (AlignGlobalForDouble(), H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[3]=((3*sizeof(CELL)+EndSpecials)|MBIT), H+=4, AbsAppl(H-4))) -#endif - -Destructor(Term, FloatOf, Float, t, (DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t)+1) : CpFloatUnaligned(RepAppl(t)))) -/* no alignment problems for 64 bit machines */ -#else - /* OOPS, YAP only understands Floats that are as large as cells or that - take two cells!!! */ -#endif -#endif - -Inline(IsFloatTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble) - - -/* extern Functor FunctorLongInt; */ -#if GC_NO_TAGS -Inline(MkLongIntTerm, Term, Int, i, (H[0] = (CELL)FunctorLongInt,H[1] = (CELL)(i),H[2]=(2*sizeof(CELL)+EndSpecials),H+=3,AbsAppl(H-3))) -#else -Inline(MkLongIntTerm, Term, Int, i, (H[0] = (CELL)FunctorLongInt,H[1] = (CELL)(i),H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3))) -#endif -Destructor(Term, LongIntOf, Int, t, RepAppl(t)[1]) -Inline(IsLongIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt) - - -#ifdef USE_GMP -#include -#include - - -MP_INT *STD_PROTO(Yap_PreAllocBigNum,(void)); -MP_INT *STD_PROTO(Yap_InitBigNum,(Int)); -Term STD_PROTO(Yap_MkBigIntTerm, (MP_INT *)); -MP_INT *STD_PROTO(Yap_BigIntOfTerm, (Term)); -void STD_PROTO(Yap_CleanBigNum,(void)); - -Inline(IsBigIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt) - -Inline(IsLargeIntTerm, int, Term, t, IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && (FunctorOfTerm(t) >= FunctorLongInt))) - -#else - -Inline(IsBigIntTerm, int, Term, t, FALSE) - -Inline(IsLargeIntTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt) - -#endif - -/* extern Functor FunctorLongInt; */ -Inline(IsLargeNumTerm, int, Term, t, IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorDouble) && (FunctorOfTerm(t) >= FunctorLongInt))) - -Inline(IsNumTerm, int, Term, t, (IsIntTerm(t) || IsLargeNumTerm(t))) - -Inline(IsAtomicTerm, Int, Term, t, IsAtomOrIntTerm(t) || IsLargeNumTerm(t)) - -Inline(IsExtensionFunctor, Int, Functor, f, f <= FunctorDouble) -Inline(IsBlobFunctor, Int, Functor, f, (f <= FunctorDouble && f >= FunctorDBRef)) -Inline(IsPrimitiveTerm, Int, Term, t, (IsAtomOrIntTerm(t) || (IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t))))) - -#ifdef TERM_EXTENSIONS - -Inline(IsAttachFunc, Int, Functor, f, FALSE) - -Inline(IsAttachedTerm, Int, Term, t, (IsVarTerm(t) && VarOfTerm(t) < H0) ) - -Inline(SafeIsAttachedTerm, Int, Term, t, (IsVarTerm(t) && VarOfTerm(t) < H0 && VarOfTerm(t) >= (CELL *)Yap_GlobalBase) ) - -Inline(ExtFromCell, exts, CELL *, pt, pt[1]) - -#else - -Inline(IsAttachFunc, Int, Functor, f, FALSE) - -Inline(IsAttachedTerm, Int, Term, t, FALSE) - - -#endif - -inline EXTERN int STD_PROTO(unify_extension,(Functor, CELL, CELL *, CELL)); - -EXTERN int STD_PROTO(unify_extension,(Functor, CELL, CELL *, CELL)); - -inline EXTERN int -unify_extension(Functor f, CELL d0, CELL *pt0, CELL d1) -{ - switch(BlobOfFunctor(f)) { - case db_ref_e: - return (d0 == d1); - case long_int_e: - return(pt0[1] == RepAppl(d1)[1]); -#ifdef USE_GMP - case big_int_e: - return (mpz_cmp(Yap_BigIntOfTerm(d0),Yap_BigIntOfTerm(d1)) == 0); -#endif /* USE_GMP */ - case double_e: - { - CELL *pt1 = RepAppl(d1); - return (pt0[1] == pt1[1] -#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT - && pt0[2] == pt1[2] -#endif - ); - } - } - return(FALSE); -} - diff --git a/m4/Yap.h.m4 b/m4/Yap.h.m4 deleted file mode 100644 index 08b301f21..000000000 --- a/m4/Yap.h.m4 +++ /dev/null @@ -1,1041 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: Yap.h.m4 * -* mods: * -* comments: main header file for YAP * -* version: $Id: Yap.h.m4,v 1.86 2007-11-13 01:52:14 pmoura Exp $ * -*************************************************************************/ - -#include "config.h" - -/* - -#define RATIONAL_TREES 1 - -#define DEPTH_LIMIT 1 - -#define COROUTINING 1 - -#define ANALYST 1 - -*/ - -#define MULTI_ASSIGNMENT_VARIABLES 1 - -#if defined(YAPOR) -#error Do not explicitly define YAPOR -#endif /* YAPOR */ - -#if (defined(ENV_COPY) && (defined(ACOW) || defined(SBA))) || (defined(ACOW) && defined(SBA)) -#error Do not define multiple or-parallel models -#endif /* (ENV_COPY && (ACOW || SBA)) || (ACOW && SBA) */ - -#if defined(ENV_COPY) || defined(ACOW) || defined(SBA) -#define YAPOR 1 -#endif /* ENV_COPY || ACOW || SBA */ - -#if defined(TABLING) && (defined(ACOW) || defined(SBA)) -#error Currently TABLING only works with ENV_COPY -#endif /* TABLING && (ACOW || SBA) */ - -#ifdef YAPOR -#define FIXED_STACKS 1 -#endif /* YAPOR */ - -#if defined(YAPOR) || defined(TABLING) -#undef TRAILING_REQUIRES_BRANCH -#endif /* YAPOR || TABLING */ - -#if ANALYST -#ifdef USE_THREADED_CODE -#undef USE_THREADED_CODE -#endif -#endif - -#ifdef COROUTINING -#ifndef TERM_EXTENSIONS -#define TERM_EXTENSIONS 1 -#endif -#endif - -#if SUPPORT_THREADS || SUPPORT_CONDOR -#define USE_SYSTEM_MALLOC 1 -#endif - -#if defined(TABLING) || defined(SBA) -#define FROZEN_STACKS 1 -#endif /* TABLING || SBA */ - -#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */ -/* adjust a config.h from mingw32 to work with vc++ */ -#ifdef HAVE_GCC -#undef HAVE_GCC -#endif -#ifdef USE_THREADED_CODE -#undef USE_THREADED_CODE -#endif -#define inline __inline -#define YAP_VERSION "Yap-5.1.3" -#define BIN_DIR "c:\\Program Files\\Yap\\bin" -#define LIB_DIR "c:\\Program Files\\Yap\\lib\\Yap" -#define SHARE_DIR "c:\\Program Files\\Yap\\share\\Yap" -#ifdef HOST_ALIAS -#undef HOST_ALIAS -#endif -#define HOST_ALIAS "i386-pc-win32" -#ifdef HAVE_IEEEFP_H -#undef HAVE_IEEEFP_H -#endif -#ifdef HAVE_UNISTD_H -#undef HAVE_UNISTD_H -#endif -#ifdef HAVE_SYS_TIME_H -#undef HAVE_SYS_TIME_H -#endif -#endif - -#ifdef __MINGW32__ -#ifndef _WIN32 -#define _WIN32 1 -#endif -#endif - -#if HAVE_GCC -#define MIN_ARRAY 0 -#define DUMMY_FILLER_FOR_ABS_TYPE -#else -#define MIN_ARRAY 1 -#define DUMMY_FILLER_FOR_ABS_TYPE int dummy; -#endif - -#ifndef ADTDEFS_C -#define EXTERN static -#else -#define EXTERN -#endif - -/* truth-values */ -#define TRUE 1 -#define FALSE 0 - -/* null pointer */ -#define NIL 0 - -/* Basic types */ - -/* defines integer types Int and UInt (unsigned) with the same size as a ptr -** and integer types Short and UShort with half the size of a ptr -*/ - -#ifdef THREADS -#if USE_PTHREAD_LOCKING -#define _XOPEN_SOURCE 600 -#endif -#include -#endif - -#if defined(YAPOR) || defined(THREADS) -#define MAX_WORKERS (sizeof(unsigned long) * 8) -#else -#define MAX_WORKERS 1 -#endif /* YAPOR */ - -#if SIZEOF_INT_P==4 - -#if SIZEOF_INT==4 -/* */ typedef int Int; -/* */ typedef unsigned int UInt; - -#elif SIZEOF_LONG_INT==4 -/* */ typedef long int Int; -/* */ typedef unsigned long int UInt; - -#else -# error Yap require integer types of the same size as a pointer -#endif - -#if SIZEOF_SHORT_INT==2 -/* */ typedef short int Short; -/* */ typedef unsigned short int UShort; - -#else -# error Yap requires integer types half the size of a pointer -#endif - -#elif SIZEOF_INT_P==8 - -# if SIZEOF_INT==8 -/* */ typedef int Int; -/* */ typedef unsigned int UInt; - -#elif SIZEOF_LONG_INT==8 -/* */ typedef long int Int; -/* */ typedef unsigned long int UInt; - -# elif SIZEOF_LONG_LONG_INT==8 -/* */ typedef long long int Int; -/* */ typedef unsigned long long int UInt; - -# else -# error Yap requires integer types of the same size as a pointer -# endif - -# if SIZEOF_SHORT_INT==4 -/* */ typedef short int Short; -/* */ typedef unsigned short int UShort; - -# elif SIZEOF_INT==4 -/* */ typedef int Short; -/* */ typedef short int UShort; - -# else -# error Yap requires integer types half the size of a pointer -# endif - -#else - -# error Yap requires pointers of size 4 or 8 - -#endif - -/* */ typedef double Float; - -#if SIZEOF_INT -#elif USE_PTHREAD_LOCKING - -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 -#endif - -typedef pthread_mutex_t lockvar; -typedef pthread_rwlock_t rwlock_t; -#include -#elif defined(i386) -typedef volatile int lockvar; -#include -#elif defined(sparc) || defined(__sparc) -typedef volatile int lockvar; -#include -#elif defined(mips) -typedef volatile int lockvar; -#include -#elif defined(__alpha) -typedef volatile int lockvar; -#include -#else - -#ifndef _XOPEN_SOURCE -#define _XOPEN_SOURCE 600 -#endif - -typedef pthread_mutex_t lockvar; -typedef pthread_rwlock_t rwlock_t; -#include -#endif - -/********************** use an auxiliary function for ranges ************/ - -#ifdef __GNUC__ -#define IN_BETWEEN(MIN,X,MAX) (Unsigned((Int)(X)-(Int)(MIN)) <= \ - Unsigned((Int)(MAX)-(Int)(MIN)) ) - -#define OUTSIDE(MIN,X,MAX) (Unsigned((Int)(X)-(Int)(MIN)) > \ - Unsigned((Int)(MAX)-(Int)(MIN)) ) -#else -#define IN_BETWEEN(MIN,X,MAX) ((void *)(X) >= (void *)(MIN) && (void *)(X) <= (void *)(MAX)) - -#define OUTSIDE(MIN,X,MAX) ((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX)) -#endif - -/* ************************* Atoms *************************************/ - -#include "Atoms.h" - -/* ************************* Coroutining **********************************/ - -#ifdef COROUTINING -/* Support for co-routining */ -#include "corout.h" -#endif - -/********* abstract machine registers **********************************/ - - -#include "amidefs.h" - -#include "Regs.h" - -#if defined(YAPOR) ||defined(THREADS) -#ifdef mips -#include -#endif -#ifdef __alpha -#include -#endif -#endif - -/************ variables concerned with Error Handling *************/ - -#include - -#if defined(SIMICS) || !HAVE_SIGSETJMP -#define sigjmp_buf jmp_buf -#define sigsetjmp(Env, Arg) setjmp(Env) -#define siglongjmp(Env, Arg) longjmp(Env, Arg) -#endif - -/* Support for arrays */ -#include "arrays.h" - -/************ variables concerned with Error Handling *************/ - -/* Types of Errors */ -typedef enum { - YAP_NO_ERROR, - FATAL_ERROR, - INTERNAL_ERROR, - INTERNAL_COMPILER_ERROR, - PURE_ABORT, - CALL_COUNTER_UNDERFLOW, - /* ISO_ERRORS */ - CONSISTENCY_ERROR, - DOMAIN_ERROR_ARRAY_OVERFLOW, - DOMAIN_ERROR_ARRAY_TYPE, - DOMAIN_ERROR_IO_MODE, - DOMAIN_ERROR_MUTABLE, - DOMAIN_ERROR_NON_EMPTY_LIST, - DOMAIN_ERROR_NOT_LESS_THAN_ZERO, - DOMAIN_ERROR_NOT_NL, - DOMAIN_ERROR_NOT_ZERO, - DOMAIN_ERROR_OUT_OF_RANGE, - DOMAIN_ERROR_OPERATOR_PRIORITY, - DOMAIN_ERROR_OPERATOR_SPECIFIER, - DOMAIN_ERROR_RADIX, - DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW, - DOMAIN_ERROR_SOURCE_SINK, - DOMAIN_ERROR_STREAM, - DOMAIN_ERROR_STREAM_OR_ALIAS, - DOMAIN_ERROR_STREAM_POSITION, - DOMAIN_ERROR_TIMEOUT_SPEC, - DOMAIN_ERROR_SYNTAX_ERROR_HANDLER, - EVALUATION_ERROR_FLOAT_OVERFLOW, - EVALUATION_ERROR_FLOAT_UNDERFLOW, - EVALUATION_ERROR_INT_OVERFLOW, - EVALUATION_ERROR_UNDEFINED, - EVALUATION_ERROR_UNDERFLOW, - EVALUATION_ERROR_ZERO_DIVISOR, - EXISTENCE_ERROR_ARRAY, - EXISTENCE_ERROR_SOURCE_SINK, - EXISTENCE_ERROR_STREAM, - INSTANTIATION_ERROR, - INTERRUPT_ERROR, - OUT_OF_HEAP_ERROR, - OUT_OF_STACK_ERROR, - OUT_OF_TRAIL_ERROR, - OUT_OF_ATTVARS_ERROR, - OUT_OF_AUXSPACE_ERROR, - PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE, - PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, - PERMISSION_ERROR_CREATE_ARRAY, - PERMISSION_ERROR_CREATE_OPERATOR, - PERMISSION_ERROR_INPUT_BINARY_STREAM, - PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM, - PERMISSION_ERROR_INPUT_STREAM, - PERMISSION_ERROR_INPUT_TEXT_STREAM, - PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE, - PERMISSION_ERROR_OPEN_SOURCE_SINK, - PERMISSION_ERROR_OUTPUT_BINARY_STREAM, - PERMISSION_ERROR_OUTPUT_STREAM, - PERMISSION_ERROR_OUTPUT_TEXT_STREAM, - PERMISSION_ERROR_RESIZE_ARRAY, - PERMISSION_ERROR_REPOSITION_STREAM, - PRED_ENTRY_COUNTER_UNDERFLOW, - REPRESENTATION_ERROR_CHARACTER, - REPRESENTATION_ERROR_CHARACTER_CODE, - REPRESENTATION_ERROR_MAX_ARITY, - RETRY_COUNTER_UNDERFLOW, - SYNTAX_ERROR, - SYSTEM_ERROR, - TYPE_ERROR_ARRAY, - TYPE_ERROR_ATOM, - TYPE_ERROR_ATOMIC, - TYPE_ERROR_BYTE, - TYPE_ERROR_CALLABLE, - TYPE_ERROR_CHAR, - TYPE_ERROR_CHARACTER, - TYPE_ERROR_COMPOUND, - TYPE_ERROR_DBREF, - TYPE_ERROR_DBTERM, - TYPE_ERROR_EVALUABLE, - TYPE_ERROR_FLOAT, - TYPE_ERROR_INTEGER, - TYPE_ERROR_KEY, - TYPE_ERROR_LIST, - TYPE_ERROR_NUMBER, - TYPE_ERROR_PREDICATE_INDICATOR, - TYPE_ERROR_PTR, - TYPE_ERROR_UBYTE, - TYPE_ERROR_UCHAR, - TYPE_ERROR_VARIABLE, - UNKNOWN_ERROR -} yap_error_number; - -typedef enum { - YAP_INT_BOUNDED_FLAG = 0, - MAX_ARITY_FLAG = 1, - INTEGER_ROUNDING_FLAG = 2, - YAP_MAX_INTEGER_FLAG = 3, - YAP_MIN_INTEGER_FLAG = 4, - CHAR_CONVERSION_FLAG = 5, - YAP_DOUBLE_QUOTES_FLAG = 6, - YAP_TO_CHARS_FLAG = 7, - LANGUAGE_MODE_FLAG = 8, - STRICT_ISO_FLAG = 9, - SPY_CREEP_FLAG = 10, - SOURCE_MODE_FLAG = 11, - CHARACTER_ESCAPE_FLAG = 12, - WRITE_QUOTED_STRING_FLAG = 13, - ALLOW_ASSERTING_STATIC_FLAG = 14, - HALT_AFTER_CONSULT_FLAG = 15, - FAST_BOOT_FLAG = 16, - STACK_DUMP_ON_ERROR_FLAG = 17, - INDEXING_MODE_FLAG = 18, - TABLING_MODE_FLAG = 19 -} yap_flags; - -#define STRING_AS_CHARS 0 -#define STRING_AS_ATOM 2 - -#define QUINTUS_TO_CHARS 0 -#define ISO_TO_CHARS 1 - -#define CPROLOG_CHARACTER_ESCAPES 0 -#define ISO_CHARACTER_ESCAPES 1 -#define SICSTUS_CHARACTER_ESCAPES 2 - -typedef enum { - INDEX_MODE_OFF = 0, - INDEX_MODE_SINGLE = 1, - INDEX_MODE_COMPACT = 2, - INDEX_MODE_MULTI = 3, - INDEX_MODE_MAX = 4 -} index_mode_options; - -typedef enum { - TABLING_MODE_OFF = 0, - TABLING_MODE_BATCHED = 1, - TABLING_MODE_LOCAL = 2, - TABLING_MODE_DEFAULT = 3 -} tabling_mode_options; - -typedef enum { - YAP_CREEP_SIGNAL = 0x1, /* received a creep */ - YAP_WAKEUP_SIGNAL = 0x2, /* goals to wake up */ - YAP_ALARM_SIGNAL = 0x4, /* received an alarm */ - YAP_HUP_SIGNAL = 0x8, /* received SIGHUP */ - YAP_USR1_SIGNAL = 0x10, /* received SIGUSR1 */ - YAP_USR2_SIGNAL = 0x20, /* received SIGUSR2 */ - YAP_INT_SIGNAL = 0x40, /* received SIGINT (unused for now) */ - YAP_ITI_SIGNAL = 0x80, /* received inter thread signal */ - YAP_TROVF_SIGNAL = 0x100, /* received trail overflow */ - YAP_CDOVF_SIGNAL = 0x200, /* received code overflow */ - YAP_STOVF_SIGNAL = 0x400, /* received stack overflow */ - YAP_TRACE_SIGNAL = 0x800, /* received start trace */ - YAP_DEBUG_SIGNAL = 0x1000, /* received start debug */ - YAP_BREAK_SIGNAL = 0x2000, /* received break signal */ - YAP_STACK_DUMP_SIGNAL= 0x4000, /* received stack dump signal */ - YAP_STATISTICS_SIGNAL= 0x8000, /* received statistics */ - YAP_DELAY_CREEP_SIGNAL= 0x10000 /* received a creep but should not do it */ -} yap_signals; - -#define NUMBER_OF_YAP_FLAGS TABLING_MODE_FLAG + 1 - -/************************ prototypes **********************************/ - -#include "Yapproto.h" - -/************************ OPTYap configuration ************************/ - -/* These must be included before unification handlers */ -#if defined(YAPOR) || defined(TABLING) -#include "opt.config.h" -#endif /* YAPOR || TABLING */ - -/***********************************************************************/ - - /* -absrectype Term = Int + Float + Atom + Pair + Appl + Ref + Var - -with AbsAppl(t) : *CELL -> Term -and RepAppl(t) : Term -> *CELL - -and AbsPair(t) : *CELL -> Term -and RepPair(t) : Term -> *CELL - -and IsIntTerm(t) = ... -and IsAtomTerm(t) = ... -and IsVarTerm(t) = ... -and IsPairTerm(t) = ... -and IsApplTerm(t) = ... -and IsFloatTerm(t) = ... -and IsRefTerm(t) = ... -and IsNonVarTerm(t) = ! IsVar(t) -and IsNumterm(t) = IsIntTerm(t) || IsFloatTerm(t) -and IsAtomicTerm(t) = IsNumTerm(t) || IsAtomTerm(t) -and IsPrimitiveTerm(t) = IsAtomicTerm(t) || IsRefTerm(t) - -and MkIntTerm(n) = ... -and MkFloatTerm(f) = ... -and MkAtomTerm(a) = ... -and MkVarTerm(r) = ... -and MkApplTerm(f,n,args) = ... -and MkPairTerm(hd,tl) = ... -and MkRefTerm(R) = ... - -and PtrOfTerm(t) : Term -> CELL * = ... -and IntOfTerm(t) : Term -> int = ... -and FloatOfTerm(t) : Term -> flt = ... -and AtomOfTerm(t) : Term -> Atom = ... -and VarOfTerm(t) : Term -> *Term = .... -and HeadOfTerm(t) : Term -> Term = ... -and TailOfTerm(t) : Term -> Term = ... -and FunctorOfTerm(t) : Term -> Functor = ... -and ArgOfTerm(i,t) : Term -> Term= ... -and RefOfTerm(t) : Term -> DBRef = ... - -*/ - -/* - YAP can use several different tag schemes, according to the kind of - machine we are experimenting with. -*/ - -#if LONG_ADDRESSES && defined(OLD_TAG_SCHEME) - -#include "Tags_32bits.h" - -#endif /* LONG_ADDRESSES && defined(OLD_TAG_SCHEME) */ - -/* AIX will by default place mmaped segments at 0x30000000. This is - incompatible with the high tag scheme. Linux-ELF also does not like - if you place things in the lower addresses (power to the libc people). -*/ - -#if (defined(_AIX) || defined(_WIN32) || defined(sparc) || defined(__sparc) || defined(mips) || defined(__FreeBSD__) || defined(_POWER) || defined(__linux__) || defined(IN_SECOND_QUADRANT) || defined(__CYGWIN__)) && !defined(TABLING) -#define USE_LOW32_TAGS 1 -#endif - -#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS) - -#include "Tags_32Ops.h" - -#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS) */ - -#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && defined(USE_LOW32_TAGS) - -#include "Tags_32LowTag.h" - -#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) */ - -#if LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME) - -#include "Tags_64bits.h" - -#endif /* LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME) */ - -#if !LONG_ADDRESSES - -#include "Tags_24bits.h" - -#endif /* !LONG_ADDRESSES */ - -#ifdef TAG_LOW_BITS_32 - -#if !GC_NO_TAGS -#define MBIT 0x80000000 -#define RBIT 0x40000000 - -#if IN_SECOND_QUADRANT -#define INVERT_RBIT 1 /* RBIT is 1 by default */ -#endif -#endif /* !GC_NO_TAGS */ - -#else - -#if !GC_NO_TAGS -#if defined(SBA) && defined(__linux__) -#define MBIT /* 0x20000000 */ MKTAG(0x1,0) /* mark bit */ -#else -#define RBIT /* 0x20000000 */ MKTAG(0x1,0) /* relocation chain bit */ -#define MBIT /* 0x40000000 */ MKTAG(0x2,0) /* mark bit */ -#endif -#endif /* !GC_NO_TAGS */ - -#endif - -#define TermSize sizeof(Term) - -/************* variables related to memory allocation *******************/ -/* must be before TermExt.h */ - -extern ADDR Yap_HeapBase; - -/* This is ok for Linux, should be ok for everyone */ -#define YAP_FILENAME_MAX 1024 - -#define MAX_ERROR_MSG_SIZE YAP_FILENAME_MAX - -#ifdef THREADS -typedef struct thread_globs { - ADDR local_base; - ADDR global_base; - ADDR trail_base; - ADDR trail_top; - char *error_message; - Term error_term; - Term error_type; - UInt error_size; - char error_say[MAX_ERROR_MSG_SIZE]; - jmp_buf io_botch; - sigjmp_buf restart_env; - struct TOKEN *tokptr; - struct TOKEN *toktide; - struct VARSTRUCT *var_table; - struct VARSTRUCT *anon_var_table; - int eot_before_eof; - char file_name_buf[YAP_FILENAME_MAX]; - char file_name_buf2[YAP_FILENAME_MAX]; - -} tglobs; - -extern struct thread_globs Yap_thread_gl[MAX_WORKERS]; - - -#define Yap_LocalBase Yap_thread_gl[worker_id].local_base -#define Yap_GlobalBase Yap_thread_gl[worker_id].global_base -#define Yap_TrailBase Yap_thread_gl[worker_id].trail_base -#define Yap_TrailTop Yap_thread_gl[worker_id].trail_top -#define Yap_ErrorMessage Yap_thread_gl[worker_id].error_message -#define Yap_Error_Term Yap_thread_gl[worker_id].error_term -#define Yap_Error_TYPE Yap_thread_gl[worker_id].error_type -#define Yap_Error_Size Yap_thread_gl[worker_id].error_size -#define Yap_ErrorSay Yap_thread_gl[worker_id].error_say -#define Yap_RestartEnv Yap_thread_gl[worker_id].restart_env -#else -extern ADDR Yap_HeapBase, - Yap_LocalBase, - Yap_GlobalBase, - Yap_TrailBase, - Yap_TrailTop; - -extern sigjmp_buf Yap_RestartEnv; /* used to restart after an abort */ - -extern char *Yap_ErrorMessage; /* used to pass error messages */ -extern Term Yap_Error_Term; /* used to pass error terms */ -extern yap_error_number Yap_Error_TYPE; /* used to pass the error */ -extern UInt Yap_Error_Size; /* used to pass the error */ - -/******************* storing error messages ****************************/ -extern char Yap_ErrorSay[MAX_ERROR_MSG_SIZE]; - -#endif - -#ifdef DEBUG -/************** Debugging Support ***************************/ -extern int Yap_output_msg; -#endif - - -/* applies to unbound variables */ -Destructor(Term, VarOf, Term *, t, t) -#if SBA -Inline0(MkVarTerm, Term, (*H = 0, H++)) -Inline(IsUnboundVar, int, Term *, t, *(t) == 0) -#else -Inline0(MkVarTerm, Term, (*H = (CELL) H, H++)) -Inline(IsUnboundVar, int, Term *, t, *(t) == (Term)(t)) -#endif -Inline(PtrOfTerm, CELL *, Term, t, *(CELL *)(t)) - -Inline(FunctorOfTerm, Functor, Term, t, *RepAppl(t)) -#if USE_SYSTEM_MALLOC || USE_DL_MALLOC -#if USE_LOW32_TAGS -Inline(MkAtomTerm, Term, Atom, a, (AtomTag | (CELL)(a))) -Destructor(Term, AtomOf, Atom, t, (~AtomTag & (CELL)(t))) -#else -Inline(MkAtomTerm, Term, Atom, a, TAGGEDA(AtomTag, (CELL)(a))) -Destructor(Term, AtomOf, Atom, t, NonTagPart(t)) -#endif -#else -Inline(MkAtomTerm, Term, Atom, a, TAGGEDA(AtomTag, (CELL)(a)-HEAP_INIT_BASE)) -Destructor(Term, AtomOf, Atom, t, HEAP_INIT_BASE+NonTagPart(t)) -#endif -Inline(IsAtomTerm, int, Term, t, CHKTAG((t), AtomTag)) - -Inline(MkIntTerm, Term, Int, n, TAGGED(NumberTag, (n))) -/* - A constant to subtract or add to a well-known term, we assume no - overflow problems are possible -*/ -Inline(MkIntConstant, Term, Int, n, NONTAGGED(NumberTag, (n))) -Inline(IsIntTerm, int, Term, t, CHKTAG((t), NumberTag)) - -EXTERN inline Term STD_PROTO(MkPairTerm,(Term,Term)); - -EXTERN inline Term -MkPairTerm(Term head, Term tail) -{ - register CELL *p = H; - - H[0] = head; - H[1] = tail; - H+=2; - return (AbsPair(p)); -} - - -/* Needed to handle numbers: - these two macros are fundamental in the integer/float conversions */ - -#ifdef M_WILLIAMS -#define IntInBnd(X) (TRUE) -#else -#ifdef TAGS_FAST_OPS -#define IntInBnd(X) (Unsigned( ( (Int)(X) >> (32-7) ) + 1) <= 1) -#else -#define IntInBnd(X) ( (X) < MAX_ABS_INT && \ - (X) > -MAX_ABS_INT-1L ) -#endif -#endif -#ifdef C_PROLOG -#define FlIsInt(X) ( (X) == (Int)(X) && IntInBnd((X)) ) -#else -#define FlIsInt(X) ( FALSE ) -#endif - - -/* - There are two types of functors: - - o Special functors mark special terms - on the heap that should be seen as constants. - - o Standard functors mark normal applications. - -*/ - -#include "TermExt.h" - -#define IsAccessFunc(func) ((func) == FunctorAccess) - -Inline(MkIntegerTerm, Term, Int, n, IntInBnd(n) ? MkIntTerm(n) : MkLongIntTerm(n)) -Inline(IsIntegerTerm, int, Term, t, IsIntTerm(t) || IsLongIntTerm(t)) -Inline(IntegerOfTerm, Int, Term, t, IsIntTerm(t) ? IntOfTerm(t) : LongIntOfTerm(t)) - - -/*************** unification routines ***********************************/ - -#if SBA -#include "sbaamiops.h" -#else -#include "amiops.h" -#endif - -/*************** High level macros to access arguments ******************/ - -Inline2(ArgOfTerm, Term, int, i, Term, t, Derefa(RepAppl(t) + (i))) -Inline(HeadOfTerm, Term, Term, t, Derefa(RepPair(t))) -Inline(TailOfTerm, Term, Term, t, Derefa(RepPair(t) + 1)) - -Inline2(ArgOfTermCell, Term, int, i, Term, t, (CELL)(RepAppl(t) + (i))) -Inline(HeadOfTermCell, Term, Term, t, (CELL)(RepPair(t))) -Inline(TailOfTermCell, Term, Term, t, (CELL)(RepPair(t) + 1)) - -/*************** variables concerned with atoms table *******************/ -#define MaxHash 1001 - -#define FAIL_RESTORE 0 -#define DO_EVERYTHING 1 -#define DO_ONLY_CODE 2 - - -#ifdef EMACS - -/******************** using Emacs mode ********************************/ - -extern int emacs_mode; - -#endif - - -/********* common instructions codes*************************/ - -#define MAX_PROMPT 256 - -#if USE_THREADED_CODE - -/************ reverse lookup of instructions *****************/ -typedef struct opcode_tab_entry { - OPCODE opc; - op_numbers opnum; -} opentry; - -#endif - -/********* Prolog may be in several modes *******************************/ - -typedef enum { - BootMode = 0x1, /* if booting or restoring */ - UserMode = 0x2, /* Normal mode */ - CritMode = 0x4, /* If we are meddling with the heap */ - AbortMode = 0x8, /* expecting to abort */ - InterruptMode = 0x10, /* under an interrupt */ - InErrorMode = 0x20, /* under an interrupt */ - ConsoleGetcMode = 0x40, /* blocked reading from console */ - ExtendStackMode = 0x80, /* trying to extend stack */ - GrowHeapMode = 0x100, /* extending Heap */ - GrowStackMode = 0x200, /* extending Stack */ - GCMode = 0x400, /* doing Garbage Collecting */ - ErrorHandlingMode = 0x800, /* doing error handling */ - CCallMode = 0x1000, /* In c Call */ - UnifyMode = 0x2000, /* In Unify Code */ - UserCCallMode = 0x4000 /* In User C-call Code */ -} prolog_exec_mode; - -extern prolog_exec_mode Yap_PrologMode; -extern int Yap_CritLocks; - -/************** Access to yap initial arguments ***************************/ - -extern char **Yap_argv; -extern int Yap_argc; - -/******** whether Yap is responsible for signal handling ******************/ - -extern int Yap_PrologShouldHandleInterrupts; - -/******************* number of modules ****************************/ - -#define MaxModules 256 - -#if YAPOR -#define YAPEnterCriticalSection() \ - { \ - if (worker_id != GLOBAL_LOCKS_who_locked_heap) { \ - LOCK(GLOBAL_LOCKS_heap_access); \ - GLOBAL_LOCKS_who_locked_heap = worker_id; \ - } \ - Yap_PrologMode |= CritMode; \ - Yap_CritLocks++; \ - } -#define YAPLeaveCriticalSection() \ - { \ - Yap_CritLocks--; \ - if (!Yap_CritLocks) { \ - Yap_PrologMode &= ~CritMode; \ - if (Yap_PrologMode & InterruptMode) { \ - Yap_PrologMode &= ~InterruptMode; \ - Yap_ProcessSIGINT(); \ - } \ - if (Yap_PrologMode & AbortMode) { \ - Yap_PrologMode &= ~AbortMode; \ - Yap_Error(PURE_ABORT, 0, ""); \ - } \ - GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \ - UNLOCK(GLOBAL_LOCKS_heap_access); \ - } \ - } -#elif THREADS -#define YAPEnterCriticalSection() \ - { \ - LOCK(BGL); \ - Yap_PrologMode |= CritMode; \ - } -#define YAPLeaveCriticalSection() \ - { \ - Yap_PrologMode &= ~CritMode; \ - if (Yap_PrologMode & InterruptMode) { \ - Yap_PrologMode &= ~InterruptMode; \ - Yap_ProcessSIGINT(); \ - } \ - if (Yap_PrologMode & AbortMode) { \ - Yap_PrologMode &= ~AbortMode; \ - Yap_Error(PURE_ABORT, 0, ""); \ - } \ - UNLOCK(BGL); \ - } -#else -#define YAPEnterCriticalSection() \ - { \ - Yap_PrologMode |= CritMode; \ - Yap_CritLocks++; \ - } -#define YAPLeaveCriticalSection() \ - { \ - Yap_CritLocks--; \ - if (!Yap_CritLocks) { \ - Yap_PrologMode &= ~CritMode; \ - if (Yap_PrologMode & InterruptMode) { \ - Yap_PrologMode &= ~InterruptMode; \ - Yap_ProcessSIGINT(); \ - } \ - if (Yap_PrologMode & AbortMode) { \ - Yap_PrologMode &= ~AbortMode; \ - Yap_Error(PURE_ABORT, 0, ""); \ - } \ - } \ - } -#endif /* YAPOR */ - -/* when we are calling the InitStaff procedures */ -#define AT_BOOT 0 -#define AT_RESTORE 1 - -/********* mutable variables ******************/ - -/* I assume that the size of this structure is a multiple of the size - of CELL!!! */ -typedef struct TIMED_MAVAR{ - CELL value; - CELL clock; -} timed_var; - -/********* while debugging you may need some info ***********************/ - -#if EMACS -extern char emacs_tmp[], emacs_tmp2[]; -#endif - -#if defined(YAPOR) || defined(TABLING) -#include "opt.structs.h" -#include "opt.proto.h" -#include "opt.macros.h" -#endif /* YAPOR || TABLING */ - -#if SBA -#include "sbaunify.h" -#endif - diff --git a/m4/Yatom.h.m4 b/m4/Yatom.h.m4 deleted file mode 100644 index 140ba3973..000000000 --- a/m4/Yatom.h.m4 +++ /dev/null @@ -1,573 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: YAtom.h.m4 * -* Last rev: 19/2/88 * -* mods: * -* comments: atom properties header file for YAP * -* * -*************************************************************************/ - -/* This code can only be defined *after* including Regs.h!!! */ - -#if USE_OFFSETS -Constructor(Atom, Abs, AtomEntry *, p, Addr(p) - AtomBase) -Destructor(Atom, Rep, AtomEntry *, a, AtomBase + Unsigned(a)) -#else -Constructor(Atom, Abs, AtomEntry *, p, p) -Destructor(Atom, Rep, AtomEntry *, a, a) -#endif - -#if USE_OFFSETS_IN_PROPS -Constructor(Prop,Abs,PropEntry *,p,Addr(p)-AtomBase) -Destructor(Prop,Rep,PropEntry *,p,AtomBase+Unsigned(p)) -#else -Constructor(Prop,Abs,PropEntry *,p,p) -Destructor(Prop,Rep,PropEntry *,p,p) -#endif - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop, RepFunctor, FunctorEntry *, p, AtomBase + Unsigned(p)) -Constructor(Prop, AbsFunctor, FunctorEntry *, p, Addr(p)-AtomBase) -#else -Destructor(Prop, RepFunctor, FunctorEntry *, p, p) -Constructor(Prop, AbsFunctor, FunctorEntry *, p, p) -#endif - -Inline(ArityOfFunctor, Int, Functor, Fun, ((FunctorEntry *)Fun)->ArityOfFE) -Inline(NameOfFunctor, Atom, Functor, Fun, ((FunctorEntry *)Fun)->NameOfFE) - -Inline(IsFunctorProperty, PropFlags, int, flags, (flags == FunctorProperty) ) - -/* summary of property codes used - - 00 00 predicate entry - 80 00 db property - bb 00 functor entry - ff df sparse functor - ff ex arithmetic property - ff f7 array - ff fa module property - ff fb blackboard property - ff fc value property - ff ff op property -*/ - -/* Module property */ -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - SMALLUNSGN IndexOfMod; /* index in module table */ -} ModEntry; - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepMod,ModEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsMod,ModEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepMod,ModEntry *,p,p) -Constructor(Prop,AbsMod,ModEntry *,p,p) -#endif - -#define ModProperty ((PropFlags)0xfffa) - -Inline(IsModProperty, PropFlags, int, flags, (flags == ModProperty)) - -/* operator property entry structure */ -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t OpRWLock; /* a read-write lock to protect the entry */ -#endif - BITS16 Prefix, Infix, Posfix; /* precedences */ - } OpEntry; -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepOp,OpEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsOp,OpEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepOp,OpEntry *,p,p) -Constructor(Prop,AbsOp,OpEntry *,p,p) -#endif -#define OpProperty ((PropFlags)0xffff) - -Inline(IsOpProperty, PropFlags, int, flags, (flags == OpProperty) ) - -/* defines related to operator specifications */ -#define MaskPrio 0x0fff -#define DcrlpFlag 0x1000 -#define DcrrpFlag 0x2000 - -typedef union arith_ret *eval_ret; - -/* expression property entry structure */ -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - unsigned int ArityOfEE; - BITS16 ENoOfEE; - BITS16 FlagsOfEE; - /* operations that implement the expression */ - union { - blob_type (*constant)(eval_ret); - blob_type (*unary)(Term, eval_ret); - blob_type (*binary)(Term, Term, eval_ret); - } FOfEE; -} ExpEntry; -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepExp,ExpEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsExp,ExpEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepExp,ExpEntry *,p,p) -Constructor(Prop,AbsExp,ExpEntry *,p,p) -#endif -#define ExpProperty 0xffe0 - -/* only unary and binary expressions are acceptable */ -Inline(IsExpProperty, PropFlags, int, flags, (flags == ExpProperty) ) - - -/* value property entry structure */ -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t VRWLock; /* a read-write lock to protect the entry */ -#endif - Term ValueOfVE; /* (atomic) value associated with the atom */ - } ValEntry; -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepVal,ValEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsVal,ValEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepVal,ValEntry *,p,p) -Constructor(Prop,AbsVal,ValEntry *,p,p) -#endif -#define ValProperty ((PropFlags)0xfffc) - -Inline(IsValProperty, PropFlags, int, flags, (flags == ValProperty) ) - -/* predicate property entry structure */ -/* AsmPreds are things like var, nonvar, atom ...which are implemented - through dedicated machine instructions. In this case the 8 lower - bits of PredFlags are used to hold the machine instruction code - for the pred. - C_Preds are things write, read, ... implemented in C. In this case - CodeOfPred holds the address of the correspondent C-function. -*/ -typedef enum { - MegaClausePredFlag = 0x80000000L, /* predicate is implemented as a mega-clause */ - ThreadLocalPredFlag = 0x40000000L, /* local to a thread */ - MultiFileFlag = 0x20000000L, /* is multi-file */ - UserCPredFlag = 0x10000000L, /* CPred defined by the user */ - LogUpdatePredFlag= 0x08000000L, /* dynamic predicate with log. upd. sem. */ - InUsePredFlag = 0x04000000L, /* count calls to pred */ - CountPredFlag = 0x02000000L, /* count calls to pred */ - HiddenPredFlag = 0x01000000L, /* invisible predicate */ - CArgsPredFlag = 0x00800000L, /* SWI-like C-interface pred. */ - SourcePredFlag = 0x00400000L, /* static predicate with source declaration */ - MetaPredFlag = 0x00200000L, /* predicate subject to a meta declaration */ - SyncPredFlag = 0x00100000L, /* has to synch before it can execute*/ - NumberDBPredFlag = 0x00080000L, /* entry for a number key */ - AtomDBPredFlag = 0x00040000L, /* entry for an atom key */ - GoalExPredFlag = 0x00020000L, /* predicate that is called by goal_expand */ - TestPredFlag = 0x00010000L, /* is a test (optim. comit) */ - AsmPredFlag = 0x00008000L, /* inline */ - StandardPredFlag = 0x00004000L, /* system predicate */ - DynamicPredFlag = 0x00002000L, /* dynamic predicate */ - CPredFlag = 0x00001000L, /* written in C */ - SafePredFlag = 0x00000800L, /* does not alter arguments */ - CompiledPredFlag = 0x00000400L, /* is static */ - IndexedPredFlag = 0x00000200L, /* has indexing code */ - SpiedPredFlag = 0x00000100L, /* is a spy point */ - BinaryTestPredFlag = 0x00000080L, /* test predicate */ - TabledPredFlag = 0x00000040L, /* is tabled */ - SequentialPredFlag = 0x00000020L, /* may not create parallel choice points! */ - ProfiledPredFlag = 0x00000010L, /* pred is being profiled */ - LocalSchedPredFlag = 0x00000008L /* use local scheduling as default for tabling */ -} pred_flag; - -/* profile data */ -typedef struct { - YAP_ULONG_LONG NOfEntries; /* nbr of times head unification succeeded*/ - YAP_ULONG_LONG NOfHeadSuccesses; /* nbr of times head unification succeeded*/ - YAP_ULONG_LONG NOfRetries; /* nbr of times a clause for the pred - was retried */ -#if defined(YAPOR) || defined(THREADS) - lockvar lock; /* a simple lock to protect this entry */ -#endif -} profile_data; - -typedef struct pred_entry { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - struct yami *CodeOfPred; - OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */ - CELL PredFlags; - unsigned int ArityOfPE; /* arity of property */ - union { - struct { - struct yami *TrueCodeOfPred; /* code address */ - struct yami *FirstClause; - struct yami *LastClause; - UInt NOfClauses; - OPCODE ExpandCode; - } p_code; - CPredicate f_code; - CmpPredicate d_code; - } cs; /* if needing to spy or to lock */ - Functor FunctorOfPred; /* functor for Predicate */ - union { - Atom OwnerFile; /* File where the predicate was defined */ - Int IndxId; /* Index for a certain key */ - struct mfile *file_srcs; /* for multifile predicates */ - } src; -#if defined(YAPOR) || defined(THREADS) - rwlock_t PRWLock; /* a simple lock to protect this entry */ - lockvar PELock; /* a simple lock to protect expansion */ -#endif -#ifdef TABLING - tab_ent_ptr TableOfPred; -#endif /* TABLING */ - Term ModuleOfPred; /* module for this definition */ - /* This must be at an odd number of cells, otherwise it - will not be aligned on RISC machines */ - profile_data StatisticsForPred; /* enable profiling for predicate */ - struct pred_entry *NextPredOfModule; /* next pred for same module */ -} PredEntry; -#define PEProp ((PropFlags)(0x0000)) - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepPred,PredEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsPred,PredEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepPred,PredEntry *,p,p) -Constructor(Prop,AbsPred,PredEntry *,p,p) -#endif - -Inline(IsPredProperty, PropFlags, int, flags, (flags == PEProp) ) - -/* Flags for code or dbase entry */ -/* There are several flags for code and data base entries */ -typedef enum { - MegaMask = 0x200000, /* informs this is a mega clause */ - FactMask = 0x100000, /* informs this is a fact */ - SwitchRootMask= 0x80000, /* informs this is the root for the index tree */ - SwitchTableMask=0x40000, /* informs this is a switch table */ - HasBlobsMask = 0x20000, /* informs this has blobs which may be in use */ - GcFoundMask = 0x10000, /* informs this is a dynamic predicate */ - DynamicMask = 0x8000, /* informs this is a dynamic predicate */ - InUseMask = 0x4000, /* informs this block is being used */ - ErasedMask = 0x2000, /* informs this block has been erased */ - IndexMask = 0x1000, /* informs this is indexing code */ - DBClMask = 0x0800, /* informs this is a data base structure */ - LogUpdRuleMask= 0x0400, /* informs the code is for a log upd rule with env */ - LogUpdMask = 0x0200, /* informs this is a logic update index. */ - StaticMask = 0x0100 /* dealing with static predicates */ -/* other flags belong to DB */ -} dbentry_flags; - -/* *********************** DBrefs **************************************/ - -typedef struct DB_TERM { -#ifdef COROUTINING - CELL attachments; /* attached terms */ -#endif - struct DB_STRUCT **DBRefs; /* pointer to other references */ - CELL NOfCells; /* Size of Term */ - CELL Entry; /* entry point */ - Term Contents[MIN_ARRAY]; /* stored term */ -} DBTerm; - -/* The ordering of the first 3 fields should be compatible with lu_clauses */ -typedef struct DB_STRUCT { - Functor id; /* allow pointers to this struct to id */ - /* as dbref */ - CELL Flags; /* Term Flags */ -#if defined(YAPOR) || defined(THREADS) - lockvar lock; /* a simple lock to protect this entry */ - Int ref_count; /* how many branches are using this entry */ -#endif - CELL NOfRefsTo; /* Number of references pointing here */ - struct struct_dbentry *Parent; /* key of DBase reference */ - struct yami *Code; /* pointer to code if this is a clause */ - struct DB_STRUCT *Prev; /* Previous element in chain */ - struct DB_STRUCT *Next; /* Next element in chain */ - struct DB_STRUCT *p, *n; /* entry's age, negative if from recorda, - positive if it was recordz */ - CELL Mask; /* parts that should be cleared */ - CELL Key; /* A mask that can be used to check before - you unify */ - DBTerm DBT; -} DBStruct; - -#define DBStructFlagsToDBStruct(X) ((DBRef)((char *)(X) - (CELL) &(((DBRef) NULL)->Flags))) - -#if defined(YAPOR) || defined(THREADS) -#define INIT_DBREF_COUNT(X) (X)->ref_count = 0 -#define INC_DBREF_COUNT(X) (X)->ref_count++ -#define DEC_DBREF_COUNT(X) (X)->ref_count-- -#define DBREF_IN_USE(X) ((X)->ref_count != 0) -#else -#define INIT_DBREF_COUNT(X) -#define INC_DBREF_COUNT(X) -#define DEC_DBREF_COUNT(X) -#define DBREF_IN_USE(X) ((X)->Flags & InUseMask) -#endif - -typedef DBStruct *DBRef; - -/* extern Functor FunctorDBRef; */ -Inline(IsDBRefTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef) -Inline(MkDBRefTerm, Term, DBRef, p, (AbsAppl(((CELL *)(p))))) -Destructor(Term, DBRefOf, DBRef, t, ((DBRef)(RepAppl(t)))) - -Inline(IsRefTerm, int, Term, t, IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef) -Destructor(Term, RefOf, CODEADDR, t, DBRefOfTerm(t)) - -typedef struct struct_dbentry { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - unsigned int ArityOfDB; /* kind of property */ - Functor FunctorOfDB; /* functor for this property */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t DBRWLock; /* a simple lock to protect this entry */ -#endif - DBRef First; /* first DBase entry */ - DBRef Last; /* last DBase entry */ - Term ModuleOfDB; /* module for this definition */ - DBRef F0,L0; /* everyone */ -} DBEntry; -typedef DBEntry *DBProp; -#define DBProperty ((PropFlags)0x8000) - -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - unsigned int ArityOfDB; /* kind of property */ - Functor FunctorOfDB; /* functor for this property */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t DBRWLock; /* a simple lock to protect this entry */ -#endif - DBRef First; /* first DBase entry */ - DBRef Last; /* last DBase entry */ - Term ModuleOfDB; /* module for this definition */ - Int NOfEntries; /* age counter */ - DBRef Index; /* age counter */ -} LogUpdDBEntry; -typedef LogUpdDBEntry *LogUpdDBProp; -#define LogUpdDBBit 0x1 -#define CodeDBBit 0x2 - -#define LogUpdDBProperty ((PropFlags)(0x8000|LogUpdDBBit)) -#define CodeLogUpdDBProperty (DBProperty|LogUpdDBBit|CodeDBBit) -#define CodeDBProperty (DBProperty|CodeDBBit) - -Inline(IsDBProperty, PropFlags, int, flags, ((flags & ~(LogUpdDBBit|CodeDBBit)) == DBProperty) ) - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepDB,DBProp,p,AtomBase + Unsigned(p)) -Constructor(Prop,AbsDB,DBProp,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepDB,DBProp,p,p) -Constructor(Prop,AbsDB,DBProp,p,p) -#endif - - -/* These are the actual flags for DataBase terms */ -typedef enum { - DBAtomic = 0x1, - DBVar = 0x2, - DBNoVars = 0x4, - DBComplex = 0x8, - DBCode = 0x10, - DBNoCode = 0x20, - DBWithRefs = 0x40 -} db_term_flags; - -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - Atom KeyOfBB; /* functor for this property */ - DBTerm *Element; /* blackboard element */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t BBRWLock; /* a read-write lock to protect the entry */ -#endif - Term ModuleOfBB; /* module for this definition */ -} BlackBoardEntry; -typedef BlackBoardEntry *BBProp; - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepBB,BlackBoardEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsBB,BlackBoardEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepBB,BlackBoardEntry *,p,p) -Constructor(Prop,AbsBB,BlackBoardEntry *,p,p) -#endif - -#define BBProperty ((PropFlags)0xfffb) - -Inline(IsBBProperty, PropFlags, int, flags, (flags == BBProperty)) - - -/* array property entry structure */ -/* first case is for dynamic arrays */ -typedef struct array_entry { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - Int ArrayEArity; /* Arity of Array (positive) */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t ArRWLock; /* a read-write lock to protect the entry */ -#endif - struct array_entry *NextArrayE; /* Pointer to the actual array */ - Term ValueOfVE; /* Pointer to the actual array */ -} ArrayEntry; - -/* second case is for static arrays */ - -/* first, the valid types */ -typedef enum { - array_of_ints, - array_of_chars, - array_of_uchars, - array_of_doubles, - array_of_ptrs, - array_of_atoms, - array_of_dbrefs, - array_of_terms -} static_array_types; - -typedef union { - Int *ints; - char *chars; - unsigned char *uchars; - Float *floats; - AtomEntry **ptrs; - Term *atoms; - Term *dbrefs; - DBTerm **terms; -} statarray_elements; - -/* next, the actual data structure */ -typedef struct { - Prop NextOfPE; /* used to chain properties */ - PropFlags KindOfPE; /* kind of property */ - Int ArrayEArity; /* Arity of Array (negative) */ -#if defined(YAPOR) || defined(THREADS) - rwlock_t ArRWLock; /* a read-write lock to protect the entry */ -#endif - static_array_types ArrayType; /* Type of Array Elements. */ - statarray_elements ValueOfVE; /* Pointer to the Array itself */ -} StaticArrayEntry; - - -#if USE_OFFSETS_IN_PROPS -Destructor(Prop,RepArray,ArrayEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsArray,ArrayEntry *,p,Addr(p)-AtomBase) -Destructor(Prop,RepStaticArray,StaticArrayEntry *,p, AtomBase + Unsigned(p)) -Constructor(Prop,AbsStaticArray,StaticArrayEntry *,p,Addr(p)-AtomBase) -#else -Destructor(Prop,RepArray,ArrayEntry *,p,p) -Constructor(Prop,AbsArray,ArrayEntry *,p,p) -Destructor(Prop,RepStaticArray,StaticArrayEntry *,p,p) -Constructor(Prop,AbsStaticArray,StaticArrayEntry *,p,p) -#endif -#define ArrayProperty ((PropFlags)0xfff7) - -Inline(ArrayIsDynamic, int, ArrayEntry *, are, ((are)->ArrayEArity > 0 )) - -Inline(IsArrayProperty, PropFlags, int, flags, (flags == ArrayProperty) ) - -/* Proto types */ - -/* cdmgr.c */ -int STD_PROTO(Yap_RemoveIndexation,(PredEntry *)); - -/* dbase.c */ -void STD_PROTO(Yap_ErDBE,(DBRef)); -DBTerm *STD_PROTO(Yap_StoreTermInDB,(Term,int)); -DBTerm *STD_PROTO(Yap_StoreTermInDBPlusExtraSpace,(Term,UInt)); -Term STD_PROTO(Yap_FetchTermFromDB,(DBTerm *)); -void STD_PROTO(Yap_ReleaseTermFromDB,(DBTerm *)); - -/* init.c */ -Atom STD_PROTO(Yap_GetOp,(OpEntry *,int *,int)); - -/* vsc: redefined to GetAProp to avoid conflicts with Windows header files */ -Prop STD_PROTO(Yap_GetAProp,(Atom,PropFlags)); -Prop STD_PROTO(Yap_GetAPropHavingLock,(AtomEntry *,PropFlags)); - -#if THREADS -EXTERN inline PredEntry *STD_PROTO(Yap_GetThreadPred, (PredEntry *)); -#endif - -EXTERN inline Prop -PredPropByFunc(Functor f, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - FunctorEntry *fe = (FunctorEntry *)f; - - WRITE_LOCK(fe->FRWLock); - p0 = fe->PropsOfFE; - while (p0) { - PredEntry *p = RepPredProp(p0); - if (/* p->KindOfPE != 0 || only props */ - (p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) { -#if THREADS - /* Thread Local Predicates */ - if (p->PredFlags & ThreadLocalPredFlag) { - WRITE_UNLOCK(fe->FRWLock); - return AbsPredProp(Yap_GetThreadPred(p)); - } -#endif - WRITE_UNLOCK(fe->FRWLock); - return (p0); - } - p0 = p->NextOfPE; - } - return Yap_NewPredPropByFunctor(fe,cur_mod); -} - -EXTERN inline Prop -PredPropByAtom(Atom at, Term cur_mod) -/* get predicate entry for ap/arity; create it if neccessary. */ -{ - Prop p0; - AtomEntry *ae = RepAtom(at); - - WRITE_LOCK(ae->ARWLock); - p0 = ae->PropsOfAE; - while (p0) { - PredEntry *pe = RepPredProp(p0); - if ( pe->KindOfPE == PEProp && - (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { -#if THREADS - /* Thread Local Predicates */ - if (pe->PredFlags & ThreadLocalPredFlag) { - WRITE_UNLOCK(ae->ARWLock); - return AbsPredProp(Yap_GetThreadPred(pe)); - } -#endif - WRITE_UNLOCK(ae->ARWLock); - return(p0); - } - p0 = pe->NextOfPE; - } - return Yap_NewPredPropByAtom(ae,cur_mod); -} - -typedef enum { - PROLOG_MODULE = 0, - USER_MODULE = 1, - IDB_MODULE = 2, - ATTRIBUTES_MODULE = 3, - CHARSIO_MODULE = 4, - TERMS_MODULE = 5 -} default_modules; diff --git a/m4/cc_genhdrs.m4 b/m4/cc_genhdrs.m4 deleted file mode 100644 index 494c8b394..000000000 --- a/m4/cc_genhdrs.m4 +++ /dev/null @@ -1,10 +0,0 @@ -define(Inline,`#define' $1($4) (($2)($5))) -define(Inline0,`#define' $1() (($2)($3))) -define(Inline2,`#define' $1($4,$6) (($2)($7))) -define(AbsType,typedef struct _$1 { int dummy; } *$1) -define(Constructor,`#define' $2$1($4) (($1)($5))) -define(Destructor,`#define' $2$1($4) (($3)($5))) - - - - diff --git a/m4/gcc_genhdrs.m4 b/m4/gcc_genhdrs.m4 deleted file mode 100644 index fc9bbba7f..000000000 --- a/m4/gcc_genhdrs.m4 +++ /dev/null @@ -1,47 +0,0 @@ -define(Inline,` -inline EXTERN $2 $1($3); - -inline EXTERN $2 $1($3 $4) -{ - return ($2) ($5); -} -' -) -define(Inline0,` -inline EXTERN $2 $1(void); - -inline EXTERN $2 $1() -{ - return ($2) ($3); -} -' -) -define(Inline2,` -inline EXTERN $2 $1($3 $4, $5 $6); - -inline EXTERN $2 $1($3 $4, $5 $6) -{ - return ($2) ($7); -} -' -) -define(AbsType,`typedef struct _$1 { DUMMY_FILLER_FOR_ABS_TYPE } *$1') -define(Constructor,` -inline EXTERN $1 $2$1($3 $4); - -inline EXTERN $1 $2$1($3 $4) -{ - return ($1) ($5); -} -' -) -define(Destructor,` -inline EXTERN $3 $2$1($1 $4); - -inline EXTERN $3 $2$1($1 $4) -{ - return ($3) ($5); -} -' -) - diff --git a/m4/gen_ansi.m4 b/m4/gen_ansi.m4 deleted file mode 100644 index a0f2a8e5d..000000000 --- a/m4/gen_ansi.m4 +++ /dev/null @@ -1,228 +0,0 @@ -divert(-1) # do not output this trash to C -# a macro to get the hd of a list -define(m4_hd,`ifelse(index(`$1',`,'),-1,`substr(`$1',1,eval(len(`$1')-2))',dnl -`substr(`$1',1,decr(index(`$1',`,')))')') -# a macro to get the tail of a list -define(m4_tl,`ifelse(index(`$1',`,'),-1,`',dnl -`(substr(`$1',incr(index(`$1',`,')))')') - -#macros to split a string -define(substr_up_to,`substr($1,0,index($1,$2))') -define(substr_after,`substr($1,incr(index($1,$2)))') - -# a macro to iterate over members of a list -define(`foreach',dnl -`pushdef(`$1',m4_hd(`$2'))_foreach(`$1',m4_tl(`$2'),`$3')popdef(`$1')') -define(`_foreach',`$3'`ifelse($2,`',,dnl -`define(`$1',m4_hd($2))_foreach(`$1',m4_tl(`$2'),`$3')')') - -define(`m4_rev',`ifelse($#,0,,$#,1,``$1'',`m4_rev(shift($@)),`$1'')') -# same as above but backwards -define(`foreachb',`foreach(`$1',(m4_rev$2),`$3')') - -# macros to process an absmi definition -define(defami, `define(`m4_i_of',m4_inst_size)'`define(`m4_ami_args',(shift($*)))' - `case _$1:ifelse($2,`',`', - `foreach(`argspec',(shift($*)),`m4_arg(substr_up_to(argspec,:),substr_after(argspec,:))')')m4_redef(InstructionSize,m4_i_of)') - -define(endami, -`foreach(`argspec',m4_ami_args,`m4_endami(substr_up_to(argspec,:))')'`#undef InstructionSize') - - -define(m4_endami,`ifelse($1,,,#undef $1 -)') - -define(m4_arg,`m4_redef($1,(*(($2 *) (S_P+m4_i_of))))define(`m4_i_of',eval(m4_i_of+m4_$2_size))') - - -define(m4_redef,` -`#define' $1 $2') - -#define a multiple push operation -define(multiple_push,`define(`m4_i',eval($#-1))$1 -= m4_i foreach(`m4arg',(shift($*)),`m4_push1($1,`m4arg')')') - -define(m4_push1,`define(`m4_i',eval(m4_i-1))ifelse(m4arg,dummy,,`; - $1[m4_i] = (CELL) (m4arg) ')') - -define(m4_n_args,`define(`m4_n',$#)') - - -#define a multiple pop operation -define(multiple_pop,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_pop1($1)')$1 += m4_i') - -define(multiple_restore,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_restore1($1)')') - -define(multiple_shorten,`define(`m4_i',-1)foreach(`m4arg',(shift($*)),`m4_shorten1($1)')') - - -define(m4_pop1,`ifelse(m4arg,dummy,,`m4arg = (m4typeof(m4arg)) ($1[m4_i]); - ')define(`m4_i',eval(m4_i+1))') - -define(m4_restore1,`ifelse(m4arg,dummy,,`m4arg = (m4typeof(m4arg)) ($1[m4_i]); - ')define(`m4_i',eval(m4_i+1))') - -define(m4_shorten1,`ifelse(m4arg,dummy,,`m4arg = (m4typeof(m4arg)) ($1[m4_i]); - ')define(`m4_i',eval(m4_i-1))') - -define(m4typeof,`ifelse($1,S_N,int,$1,old_s,CELL,typeof($1))') - -define(typeof,`ifelse($1,X,`int',$1,S_B->cp_ap,`CELL',$1,reading,`int',`CELL *')') - -# these are machine dependent -define(m4_reg_size,1) -define(m4_small_size,1) -define(m4_long_size,1) -define(m4_inst_size,1) - -define(ShadowRegister,` -define(shadow_$1) -#define LoadShadow_$1 S_$1 = (m4typeof(S_$1)) $1; -#define StoreShadow_$1 $1 = (m4typeof($1))S_$1; -') - -define(ShadowRegisterDeclarations, -`ifdef(shadow_P,` register char *S_P; -',)' -`ifdef(shadow_Y,` register CELL *S_Y; -',) -') - -define(DerefA, dnl (ptr,NonVarCase,VarCase) -`` { - register CELL *VarValue = (CELL *)$1, NonVarValue; - while(1) { - if(IsVarTerm(NonVarValue = *VarValue) ) { - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - VarValue = (CELL *) NonVarValue; - } else { - $2; - break; - } - } - }'') - - -define(DerefD, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue, NonVarValue=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue)) { - NonVarValue = *(VarValue = (CELL *) NonVarValue); - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefD1, dnl (data,NonVarCase,VarCase) -`` { - register CELL *VarValue1, NonVarValue1=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue1)) { - NonVarValue1 = *(VarValue1 = (CELL *) NonVarValue1); - if(NonVarValue1 == (CELL) VarValue1) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefI, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue; - I_R=(CELL) $1; - while(1) { - if(IsVarTerm(I_R)) { - I_R = *(VarValue = (CELL *) I_R); - if(I_R == (CELL) VarValue) { - $3; - break; - } - } - else { $2; break; } - } - }'') - -divert - - -#define Y YENV - - -#define shadow_all() \ - TestCount = 0; \ - LoadShadow_P; \ - LoadShadow_Y; \ - -#define unshadow_all() \ - StoreShadow_P; \ - StoreShadow_Y; - -#ifndef LoadShadow_CP -#define S_CP CP -#endif - -#ifndef LoadShadow_ENV -#define S_ENV ENV -#endif - -#ifndef LoadShadow_B -#define S_B B -#endif - -#ifndef LoadShadow_H -#define S_H H -#endif - -#ifndef LoadShadow_TR -#define S_TR TR -#endif - -#ifndef LoadShadow_N -#define S_N N -#endif - -#ifndef LoadShadow_BH -#define LoadShadow_BH(X) HB = (CELL *) X -#define S_BH HB -#endif - -#ifndef LoadShadow_S -#define LoadShadow_S() -#define S_S S -#endif - -#ifndef LoadShadow_P -#define S_P P -#define LoadShadow_P -#define StoreShadow_P -#endif - -#ifndef LoadShadow_Y -#define S_Y Y -#define LoadShadow_Y -#define StoreShadow_Y -#endif - - -#define CHECK(B) if(--TestCount <= 0) { TestCount=10; B } -#define ENSURECHECK() TestCount=1 - -#define small Int -#define reg Int - - - - diff --git a/m4/gen_gcc.m4 b/m4/gen_gcc.m4 deleted file mode 100644 index 9bf9d07e6..000000000 --- a/m4/gen_gcc.m4 +++ /dev/null @@ -1,214 +0,0 @@ -divert(-1) # don t output this trash to C -# Preprocessor for i386 linux -# a macro to get the hd of a list -define(m4_hd,`ifelse(index(`$1',`,'),-1,`substr(`$1',1,eval(len(`$1')-2))',dnl -`substr(`$1',1,decr(index(`$1',`,')))')') -# a macro to get the tail of a list -define(m4_tl,`ifelse(index(`$1',`,'),-1,`',dnl -`(substr(`$1',incr(index(`$1',`,')))')') - -#macros to split a string -define(substr_up_to,`substr($1,0,index($1,$2))') -define(substr_after,`substr($1,incr(index($1,$2)))') - -# a macro to iterate over members of a list -define(`foreach',dnl -`pushdef(`$1',m4_hd(`$2'))_foreach(`$1',m4_tl(`$2'),`$3')popdef(`$1')') -define(`_foreach',`$3'`ifelse($2,`',,dnl -`define(`$1',m4_hd($2))_foreach(`$1',m4_tl(`$2'),`$3')')') - -define(`m4_rev',`ifelse($#,0,,$#,1,``$1'',`m4_rev(shift($@)),`$1'')') -# same as above but backwards -define(`foreachb',`foreach(`$1',(m4_rev$2),`$3')') - -# macros to process an absmi definition -define(defami, `define(`m4_i_of',m4_opcode_size)'`define(`m4_ami_args',(shift($*)))' - `$1:ifelse($2,`',`', - `foreach(`argspec',(shift($*)),`m4_arg(substr_up_to(argspec,:),substr_after(argspec,:))')')m4_redef(InstructionSize,m4_i_of)') - -define(endami, -`foreach(`argspec',m4_ami_args,`m4_endami(substr_up_to(argspec,:))')'`#undef InstructionSize') - - -define(m4_endami,`ifelse($1,,,#undef $1 -)') - -define(m4_arg,`m4_redef($1,(*(($2 *) (S_P+m4_i_of))))define(`m4_i_of',eval(m4_i_of+m4_$2_size))') - - -define(m4_redef,` -`#define' $1 $2') - -#define a multiple push operation -define(multiple_push,`define(`m4_i',eval($#-1))$1 -= m4_i foreach(`m4arg',(shift($*)),`m4_push1($1,`m4arg')')') - -define(m4_push1,`define(`m4_i',eval(m4_i-1))ifelse(m4arg,dummy,,`; - $1[m4_i] = (CELL) m4arg ')') - -define(m4_n_args,`define(`m4_n',$#)') - - -#define a multiple pop operation -define(multiple_pop,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_pop1($1)')$1 += m4_i') - -define(multiple_restore,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_restore1($1)')') - -define(multiple_shorten,`define(`m4_i',-1)foreach(`m4arg',(shift($*)),`m4_shorten1($1)')') - - -define(m4_pop1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i+1))') - -define(m4_restore1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i+1))') - -define(m4_shorten1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i-1))') - -# these are machine dependent -define(m4_reg_size,4) -define(m4_small_size,4) -define(m4_long_size,4) -define(m4_opcode_size,4) - -define(ShadowRegister,` -define(shadow_$1) -#define LoadShadow_$1 S_$1 = (typeof(S_$1)) $1; -#define StoreShadow_$1 $1 = (typeof($1))S_$1; -') - -define(ShadowRegisterDeclarations, -`ifdef(shadow_P,,` register char *S_P; -')' -`ifdef(shadow_Y,,` register CELL *S_Y; -') -') - -define(DerefA, dnl (ptr,NonVarCase,VarCase) -`` { - register CELL *VarValue = (CELL *)$1, NonVarValue; - while(1) { - if(IsVarTerm(NonVarValue = *VarValue) ) { - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - VarValue = (CELL *) NonVarValue; - } else { - $2; - break; - } - } - }'') - - -define(DerefD, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue, NonVarValue=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue)) { - NonVarValue = *(VarValue = (CELL *) NonVarValue); - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefD1, dnl (data,NonVarCase,VarCase) -`` { - register CELL *VarValue1, NonVarValue1=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue1)) { - NonVarValue1 = *(VarValue1 = (CELL *) NonVarValue1); - if(NonVarValue1 == (CELL) VarValue1) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefI, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue; - I_R=(CELL) $1; - while(1) { - if(IsVarTerm(I_R)) { - I_R = *(VarValue = (CELL *) I_R); - if(I_R == (CELL) VarValue) { - $3; - break; - } - } - else { $2; break; } - } - }'') - -divert - -#define Y YENV - -ShadowRegister(P) -ShadowRegister(Y) - - -#define shadow_all() \ - TestCount = 0; \ - LoadShadow_P; \ - LoadShadow_Y; \ - -#define unshadow_all() \ - StoreShadow_P; \ - StoreShadow_Y; - -#ifndef LoadShadow_CP -#define S_CP CP -#endif - -#ifndef LoadShadow_ENV -#define S_ENV ENV -#endif - -#ifndef LoadShadow_B -#define S_B B -#endif - -#ifndef LoadShadow_H -#define S_H H -#endif - -#ifndef LoadShadow_TR -#define S_TR TR -#endif - -#ifndef LoadShadow_N -#define S_N N -#endif - -#ifndef LoadShadow_BH -#define LoadShadow_BH(X) HB = (CELL *) X -#define S_BH HB -#endif - -#ifndef LoadShadow_S -#define LoadShadow_S() -#define S_S S -#endif - - - -#define CHECK(B) if(--TestCount <= 0) { TestCount=10; B } -#define ENSURECHECK() TestCount=1 - - -#define small long -#define reg long - diff --git a/m4/gen_linux.m4 b/m4/gen_linux.m4 deleted file mode 100644 index 475cf2e8f..000000000 --- a/m4/gen_linux.m4 +++ /dev/null @@ -1,228 +0,0 @@ -divert(-1) # don t output this trash to C -# Preprocessor for i386 linux -# a macro to get the hd of a list -define(m4_hd,`ifelse(index(`$1',`,'),-1,`substr(`$1',1,eval(len(`$1')-2))',dnl -`substr(`$1',1,decr(index(`$1',`,')))')') -# a macro to get the tail of a list -define(m4_tl,`ifelse(index(`$1',`,'),-1,`',dnl -`(substr(`$1',incr(index(`$1',`,')))')') - -#macros to split a string -define(substr_up_to,`substr($1,0,index($1,$2))') -define(substr_after,`substr($1,incr(index($1,$2)))') - -# a macro to iterate over members of a list -define(`foreach',dnl -`pushdef(`$1',m4_hd(`$2'))_foreach(`$1',m4_tl(`$2'),`$3')popdef(`$1')') -define(`_foreach',`$3'`ifelse($2,`',,dnl -`define(`$1',m4_hd($2))_foreach(`$1',m4_tl(`$2'),`$3')')') - -define(`m4_rev',`ifelse($#,0,,$#,1,``$1'',`m4_rev(shift($@)),`$1'')') -# same as above but backwards -define(`foreachb',`foreach(`$1',(m4_rev$2),`$3')') - -# macros to process an absmi definition -define(defami, `define(`m4_i_of',m4_opcode_size)'`define(`m4_ami_args',(shift($*)))' - `$1:ifelse($2,`',`', - `foreach(`argspec',(shift($*)),`m4_arg(substr_up_to(argspec,:),substr_after(argspec,:))')')m4_redef(InstructionSize,m4_i_of)') - -define(endami, -`foreach(`argspec',m4_ami_args,`m4_endami(substr_up_to(argspec,:))')'`#undef InstructionSize') - - -define(m4_endami,`ifelse($1,,,#undef $1 -)') - -define(m4_arg,`m4_redef($1,(*(($2 *) (S_P+m4_i_of))))define(`m4_i_of',eval(m4_i_of+m4_$2_size))') - - -define(m4_redef,` -`#define' $1 $2') - -#define a multiple push operation -define(multiple_push,`define(`m4_i',eval($#-1))$1 -= m4_i foreach(`m4arg',(shift($*)),`m4_push1($1,`m4arg')')') - -define(m4_push1,`define(`m4_i',eval(m4_i-1))ifelse(m4arg,dummy,,`; - $1[m4_i] = (CELL) m4arg ')') - -define(m4_n_args,`define(`m4_n',$#)') - - -#define a multiple pop operation -define(multiple_pop,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_pop1($1)')$1 += m4_i') - -define(multiple_restore,`define(`m4_i',0)foreachb(`m4arg',(shift($*)),`m4_restore1($1)')') - -define(multiple_shorten,`define(`m4_i',-1)foreach(`m4arg',(shift($*)),`m4_shorten1($1)')') - - -define(m4_pop1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i+1))') - -define(m4_restore1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i+1))') - -define(m4_shorten1,`ifelse(m4arg,dummy,,`m4arg = (typeof(m4arg)) $1[m4_i]; - ')define(`m4_i',eval(m4_i-1))') - -# these are machine dependent -define(m4_reg_size,2) -define(m4_small_size,2) -define(m4_long_size,4) -define(m4_opcode_size,2) - -define(ShadowRegister,` -define(shadow_$1) -#define LoadShadow_$1 S_$1 = (typeof(S_$1)) $1; -#define StoreShadow_$1 $1 = (typeof($1))S_$1; -') - -define(ShadowRegisterDeclarations, -`ifdef(shadow_P,,` register char *S_P; -')' -`ifdef(shadow_Y,,` register CELL *S_Y; -') -') - -define(DerefA, dnl (ptr,NonVarCase,VarCase) -`` { - register CELL *VarValue = (CELL *)$1, NonVarValue; - while(1) { - if(IsVarTerm(NonVarValue = *VarValue) ) { - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - VarValue = (CELL *) NonVarValue; - } else { - $2; - break; - } - } - }'') - - -define(DerefD, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue, NonVarValue=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue)) { - NonVarValue = *(VarValue = (CELL *) NonVarValue); - if(NonVarValue == (CELL) VarValue) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefD1, dnl (data,NonVarCase,VarCase) -`` { - register CELL *VarValue1, NonVarValue1=(CELL) $1; - while(1) { - if(IsVarTerm(NonVarValue1)) { - NonVarValue1 = *(VarValue1 = (CELL *) NonVarValue1); - if(NonVarValue1 == (CELL) VarValue1) { - $3; - break; - } - } else { - $2; - break; - } - } - }'') - -define(DerefI, dnl (data,NonVarCase,VarCase) - ``{ - register CELL *VarValue; - I_R=(CELL) $1; - while(1) { - if(IsVarTerm(I_R)) { - I_R = *(VarValue = (CELL *) I_R); - if(I_R == (CELL) VarValue) { - $3; - break; - } - } - else { $2; break; } - } - }'') - -divert - -#define Y YENV - -ShadowRegister(P) -ShadowRegister(Y) - - -#define shadow_all() \ - TestCount = 0; \ - LoadShadow_P; \ - LoadShadow_Y; \ - -#define unshadow_all() \ - StoreShadow_P; \ - StoreShadow_Y; - -#ifndef LoadShadow_CP -#define S_CP CP -#endif - -#ifndef LoadShadow_ENV -#define S_ENV ENV -#endif - -#ifndef LoadShadow_B -#define S_B B -#endif - -#ifndef LoadShadow_H -#define S_H H -#endif - -#ifndef LoadShadow_TR -#define S_TR TR -#endif - -#ifndef LoadShadow_N -#define S_N N -#endif - -#ifndef LoadShadow_BH -#define LoadShadow_BH(X) HB = (CELL *) X -#define S_BH HB -#endif - -#ifndef LoadShadow_S -#define LoadShadow_S() -#define S_S S -#endif - - - -#define CHECK(B) if(--TestCount <= 0) { TestCount=10; B } -#define ENSURECHECK() TestCount=1 - -#define MACHINE_SPECIFIC_MACROS - -#define EFAIL asm volatile ("jmp FAIL" : : ) -#define UFAIL asm volatile ("jmp UFAIL" : : ) -#define SaveSP(X) asm volatile ("movl %%esp,%0\n\tmovl %%ebp,_SAVEBP" : "=rm"(X) : ) -#define RestoreSP(X) asm volatile ("movl %0,%%esp\n\tmovl _SAVEBP,%%ebp" : : "r" (X)) -#define push2(X,Y) asm volatile ("pushl %0\n\tpushl %1" : : "r" (X) , "r" (Y) ) -#define stack_top(X) asm volatile ("popl %0\n\tpushl %0" : "=r" (X) : ) -#define push(X) asm volatile ("pushl %0" : : "r" (X) ) -#define pop2(X,Y) asm volatile ("popl %0\n\tpopl %1": "=r" (Y), "=r" (X) :) -#define add_sp(N) asm volatile ("addl %0,%%esp": : "r" (N)) - - - - -#define small short -#define reg short - diff --git a/m4/m4.cc b/m4/m4.cc deleted file mode 100644 index 494c8b394..000000000 --- a/m4/m4.cc +++ /dev/null @@ -1,10 +0,0 @@ -define(Inline,`#define' $1($4) (($2)($5))) -define(Inline0,`#define' $1() (($2)($3))) -define(Inline2,`#define' $1($4,$6) (($2)($7))) -define(AbsType,typedef struct _$1 { int dummy; } *$1) -define(Constructor,`#define' $2$1($4) (($1)($5))) -define(Destructor,`#define' $2$1($4) (($3)($5))) - - - - diff --git a/m4/m4.gcc b/m4/m4.gcc deleted file mode 100644 index 892c7a1f5..000000000 --- a/m4/m4.gcc +++ /dev/null @@ -1,35 +0,0 @@ -define(Inline, -EXTERN inline $2 $1($3 $4) -{ - return ($2) ($5); -} -) -define(Inline0, -EXTERN inline $2 $1() -{ - return ($2) ($3); -} -) -define(Inline2, -EXTERN inline $2 $1($3 $4,$5 $6) -{ - return ($2) ($7); -} -) -define(AbsType,typedef struct _$1 { } *$1) -define(Constructor, -EXTERN inline $1 $2$1($3 $4) -{ - return ($1) ($5); -} -) - -define(Destructor, -EXTERN inline $3 $2$1($1 $4) -{ - return ($3) ($5); -} -) - - - diff --git a/m4/sshift.h.m4 b/m4/sshift.h.m4 deleted file mode 100644 index 6b87a1e8d..000000000 --- a/m4/sshift.h.m4 +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************* -* * -* YAP Prolog %W% %G% -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: sshift.h * -* Last rev: 19/2/88 * -* mods: * -* comments: stack shifter functionality for YAP * -* * -*************************************************************************/ - - -#define CharP(ptr) ((char *) (ptr)) - -Inline(IsHeapP, int, CELL *, ptr, (ptr >= (CELL *)Yap_HeapBase && ptr <= (CELL *)HeapTop) ) - -/* Adjusting cells and pointers to cells */ -Inline(PtoGloAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + GDiff)) ) -Inline(PtoDelayAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + DelayDiff)) ) -Inline(PtoTRAdjust, tr_fr_ptr, tr_fr_ptr, ptr, ((tr_fr_ptr)(CharP(ptr) + TrDiff)) ) -Inline(CellPtoTRAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + TrDiff)) ) -Inline(PtoLocAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + LDiff)) ) -Inline(ChoicePtrAdjust, choiceptr, choiceptr, ptr, ((choiceptr)(CharP(ptr) + LDiff)) ) -#ifdef TABLING -Inline(ConsumerChoicePtrAdjust, choiceptr, choiceptr, ptr, ((choiceptr)(CharP(ptr) + LDiff)) ) -Inline(GeneratorChoicePtrAdjust, choiceptr, choiceptr, ptr, ((choiceptr)(CharP(ptr) + LDiff)) ) -#endif /* TABLING */ - -Inline(GlobalAdjust, CELL, CELL, val, (val+GDiff) ) -Inline(DelayAdjust, CELL, CELL, val, (val+DelayDiff) ) -Inline(GlobalAddrAdjust, ADDR, ADDR, ptr, (ptr+GDiff) ) -Inline(DelayAddrAdjust, ADDR, ADDR, ptr, (ptr+DelayDiff) ) -Inline(LocalAdjust, CELL, CELL, val, (val+LDiff) ) -Inline(LocalAddrAdjust, ADDR, ADDR, ptr, (ptr+LDiff) ) -Inline(TrailAdjust, CELL, CELL, val, (val+TrDiff) ) -Inline(TrailAddrAdjust, ADDR, ADDR, ptr, (ptr+TrDiff) ) -Inline(TokEntryAdjust, TokEntry *, TokEntry*, ptr, ((CELL)ptr+TrDiff) ) -Inline(VarEntryAdjust, VarEntry *, VarEntry*, ptr, ((CELL)ptr+TrDiff) ) -/* heap data structures */ -EXTERN inline Functor -FuncAdjust(Functor f) -{ - if (!IsExtensionFunctor(f)) - return (Functor)(CharP(f)+HDiff); -} -Inline(CellPtoHeapAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + HDiff)) ) -#if USE_OFFSETS -Inline(AtomAdjust, Atom, Atom, at, (at) ) -Inline(PropAdjust, Prop, Prop, p, (p) ) -#else -Inline(AtomAdjust, Atom, Atom, at, (at == NULL ? (at) : (Atom)(CharP(at)+HDiff) )) -Inline(PropAdjust, Prop, Prop, p, (p == NULL ? (p) : (Prop)(CharP(p)+HDiff)) ) -#endif -Inline(AtomTermAdjust, Term, Term, at, (at) ) -#if TAGS_FAST_OPS -Inline(BlobTermAdjust, Term, Term, t, (t-HDiff) ) -#else -Inline(BlobTermAdjust, Term, Term, t, (t+HDiff) ) -#endif -Inline(AtomEntryAdjust, AtomEntry *, AtomEntry *, at, (AtomEntry *)(CharP(at)+HDiff) ) -Inline(ConsultObjAdjust, union CONSULT_OBJ *, union CONSULT_OBJ *, co, (union CONSULT_OBJ *)(CharP(co)+HDiff) ) -Inline(DBRefAdjust, DBRef, DBRef, dbr, (DBRef)(CharP(dbr)+HDiff) ) -Inline(DBRefPAdjust, DBRef *, DBRef *, dbrp, (DBRef *)(CharP(dbrp)+HDiff) ) -Inline(DBTermAdjust, DBTerm *, DBTerm *, dbtp, (DBTerm *)(CharP(dbtp)+HDiff) ) -Inline(SIndexAdjust, struct static_index *, struct static_index *, si, (struct static_index *)(CharP(si)+HDiff) ) -Inline(LUIndexAdjust, struct logic_upd_index *, struct logic_upd_index *, lui, (struct logic_upd_index *)(CharP(lui)+HDiff) ) -Inline(CodeAdjust, Term, Term, dbr, ((Term)(dbr)+HDiff) ) -Inline(AddrAdjust, ADDR, ADDR, addr, (ADDR)(CharP(addr)+HDiff) ) -Inline(CodeAddrAdjust, CODEADDR, CODEADDR, addr, (CODEADDR)(CharP(addr)+HDiff) ) -Inline(BlockAdjust, BlockHeader *, BlockHeader *, addr, (BlockHeader *)(CharP(addr)+HDiff) ) -Inline(PtoOpAdjust, yamop *, yamop *, ptr, ((yamop *)(CharP(ptr) + HDiff)) ) -Inline(PtoHeapCellAdjust, CELL *, CELL *, ptr, ((CELL *)(CharP(ptr) + HDiff)) ) -Inline(PtoPredAdjust, PredEntry *, PredEntry *, ptr, ((PredEntry *)(CharP(ptr) + HDiff)) ) -Inline(PtoArrayEAdjust, ArrayEntry *, ArrayEntry *, ptr, ((ArrayEntry *)(CharP(ptr) + HDiff)) ) -Inline(PtoLUCAdjust, struct logic_upd_clause *, struct logic_upd_clause *, ptr, ((struct logic_upd_clause *)(CharP(ptr) + HDiff)) ) -Inline(PtoStCAdjust, struct static_clause *, struct static_clause *, ptr, ((struct static_upd_clause *)(CharP(ptr) + HDiff)) ) -#if USE_DL_MALLOC -Inline(ChunkPtrAdjust, struct malloc_chunk *, struct malloc_chunk *, ptr, ((struct malloc_chunk *)(CharP(ptr) + HDiff)) ) -#endif -#if PRECOMPUTE_REGADDRESS -Inline(XAdjust, wamreg, wamreg, reg, (wamreg)((reg)+XDiff) ) -#else -Inline(XAdjust, wamreg, wamreg, reg, (reg) ) -#endif -Inline(YAdjust, yslot, yslot, reg, (reg) ) - -Inline(IsOldLocal, int, CELL, reg, IN_BETWEEN(OldASP, reg, OldLCL0)) -Inline(IsOldLocalPtr, int, CELL *, ptr, IN_BETWEEN(OldASP, ptr, OldLCL0)) - -/* require because the trail might contain dangling pointers */ -Inline(IsOldLocalInTR, int, CELL, reg, IN_BETWEEN(OldH, reg, OldLCL0) ) -Inline(IsOldLocalInTRPtr, int, CELL *, ptr, IN_BETWEEN(OldH, ptr, OldLCL0) ) - -Inline(IsOldH, int, CELL, reg, ( CharP(reg) == CharP(OldH) ) ) - - -Inline(IsOldGlobal, int, CELL, reg, IN_BETWEEN(OldH0, reg, OldH) ) -Inline(IsOldGlobalPtr, int, CELL *, ptr, IN_BETWEEN( OldH0, ptr, OldH) ) -Inline(IsOldDelay, int, CELL, reg, IN_BETWEEN(OldGlobalBase, reg, OldH0) ) -Inline(IsOldDelayPtr, int, CELL *, ptr, IN_BETWEEN( OldGlobalBase, ptr, OldH0) ) -Inline(IsOldTrail, int, CELL, reg, IN_BETWEEN(OldTrailBase, reg, OldTR) ) -Inline(IsOldTrailPtr, int, CELL *, ptr, IN_BETWEEN(OldTrailBase, ptr, OldTR) ) -Inline(IsOldVarTableTrailPtr, int, struct VARSTRUCT *, ptr, IN_BETWEEN(OldTrailBase, ptr, OldTR) ) -Inline(IsOldTokenTrailPtr, int, struct TOKEN *, ptr, IN_BETWEEN(OldTrailBase, ptr, OldTR) ) -Inline(IsOldCode, int, CELL, reg, IN_BETWEEN(OldHeapBase, reg, OldHeapTop) ) -Inline(IsOldCodeCellPtr, int, CELL *, ptr, IN_BETWEEN(OldHeapBase, ptr, OldHeapTop) ) -Inline(IsGlobal, int, CELL, reg, IN_BETWEEN(Yap_GlobalBase, reg, H) ) - -void STD_PROTO(Yap_AdjustStacksAndTrail, (void)); -void STD_PROTO(Yap_AdjustRegs, (int)); diff --git a/misc/Yap.spec b/misc/Yap.spec index d7fd4e714..1b41ffc99 100644 --- a/misc/Yap.spec +++ b/misc/Yap.spec @@ -4,7 +4,7 @@ Name: Yap Summary: Prolog Compiler Version: 6.0.4 -Packager: Vitor Santos Costa +Packager: Vitor Santos Costa Release: 1 Source: http://www.dcc.fc.up.pt/~vsc/Yap/%{name}-%{version}.tar.gz License: Perl Artistic License @@ -16,8 +16,8 @@ Prefix: /usr BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root %description -A high-performance Prolog compiler developed at LIACC, -Universidade do Porto. The Prolog engine is based in the WAM (Warren +A high-performance Prolog compiler developed at +Universidade do Porto and Universidade Federal do Rio de Janeiro. The Prolog engine is based in the WAM (Warren Abstract Machine), with several optimizations for better performance. YAP follows the Edinburgh tradition, and is largely compatible with the ISO-Prolog standard and with Quintus and SICStus